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.GetNext - Perfom a SNMP GetNext

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,buffer,OIDName = lp.GetNext(“ip”,"oid");

Description

Perform a SNMP Get Next of one oid on the specified host IP address.

Parameters

ip - The IP address in as a charater string (xxx.xxx.xxx.xxx)

The IP address should exist in the directory

oid - A snmp object id

This is a character string of the SNMP oid to query. This OID should be imperatively define in the LoriotPro MIB database (the MIB tree)

Return Values

value : A integer value if the snmp object is an integer a gauge a counter. It return 0 if the snmp object is an octet string.

Return nil if an error occurs

buffer : Return the result of the snmp get next as a character string

OIDName : Provide the oid name of the next object to query

Return nil if an error occurs

Example

In the example below the script uses the lp_host parameter passed by LoriotPro to the script and perfom a Get Next on the oid sysname. It will return the next object in the MIB tree which is (syslocation.0).

Results are displayed in the Value out column.

If there is a syntax error in the IP parameter the return values are all at nil.

Below a more complex example where we are looking for the harddisk C: in the snmp hardware storage unit table.

OIDName="hrstoragedescr.0";
buffer = "";
lp_value = 0;
lp_buffer = "no found";
while lp_value do
lp_value ,buffer,OIDName=lp.GetNext(lp_host,OIDName);
lp.Trace(OIDName);
if (string.sub(buffer,1,2) == "C:" ) then
lp.Trace(buffer);
lp_buffer=buffer;
end;
if (string.sub(OIDName,1,14) ~= "hrstoragedescr") then break end;
end

:


www.loriotpro.com