LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.SendTrapV1 - Send a SNMP Trap in V1 format to a Trap receiver

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

value = lp.SendTrapV1('ipdest', 'ipagent', 'community', 'trapname', type, specific, 'iod1,oid2');

Description

The lp.SendTrapV1 LUA function sends a SNMP Trap in V1 format to a Trap receiver (UPD port 162).

Refers to RFC 1215

Parameters

‘ipdest’                     The IP address of the remote TRAP serveur ( Any SNMP Manager like LoriotPro).

‘ipagent’                   The IP address of the device that is the source of the TRAP V1 

‘community’            The ‘community’ used to authenticate the TRAP by the SNMP manager. 

‘trapname’               The SNMP TRAP name. 

type                         the type of the TRAP                                              

Type

Description

0

Coldstart

1

Warmstart

2

LinkDown

3

LinkUp

4

Authentication Failure

5

BGP

6

Generic enterprise TRAP

specific                      The specific number when the TRAP is of type 6 (Enterprise TRAP)

'iod1,oid2'                 A list of oid and value for each varbind of the TRAP.

The syntax should be

Oidname.index/(type)value

Type must be one of these:

syntax

Value type

(nu)

NUL

(id)

Objet ID

(hs)

Hexa string

(os)

Octet string

(in)

Integer

(ip)

IP adresse

(co)

Counter

(ga)

Gauge

(ti)

Timeticks

 

Return Values

value : value equal 1 if trap sent

Return nil if an error occurs

Example

You can use the TRAP simulator service and the Wizards of the editor to help you to create your LUA code.

Send trap v1 with LUA

First we simulate a trap from HP "CPQCMC-MIB:cpqCmc" with the Loriotpro Trap simulator service

Send trap v1 with LUA

Reception of the TRAP : CPQCMC-MIB:cpqCmc

Send trap v1 with LUA

The variables VARBIND used will be :

sysDescr/(OS)string,sysContact/(OS)string,sysName/(OS)string,sysLocation/(OS)string

The code :

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','cpqCmc',6,153100,'sysDescr/(OS)string,sysContact/(OS)string,sysName/(OS)string,sysLocation/(OS)string');

Send trap v1 with LUA 

lp_value=0;

lp_buffer="ok";  

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','coldstart',0,0,'ifindex.1');

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','warmstart',1,0,'ifindex.1');

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','linkdown',2,0,'ifindex.1');

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','linkup',3,0,'ifindex.1');

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','Authenticationfailure',4,0,'ifindex.1');

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','egpneighborloss',5,0,'ifindex.1'); 

lp.SendTrapV1('127.0.0.1','127.0.0.1','public','compaq',6,22008,'cpqRackCommonEnclosureTrapSequenceNum/(IN)145,cpqRackCommonEnclosureFanSparePartNumber/(OS)string,cpqRackCommonEnclosureFanLocation/(OS)string,cpqRackCommonEnclosureSerialNum/(OS)string,cpqRackCommonEnclosureName/(OS)string,cpqRackUid/(OS)string,cpqRackName/(OS)string,cpqHoTrapFlags/(IN)145,sysName/(OS)string')

 Send trap v1 with LUA

 

 


www.loriotpro.com