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.GetRows - Perform multiple SNMP GetNext on indexed OID

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

rownumber = lp.GetRows(ip,"oid1,oid2","arrayname");

Description

The lp.GetRows function performs SNMP GETNEXT on a list of snmp object on the host specified by IP address.

Parameters

ip - The IP address as a character string (xxx.xxx.xxx.xxx) or a variable

The IP address should exist in the directory

"oid,oid,..." - A set of snmp object id

This is a character string of a set of SNMP oids. These OID should be imperatively defined in the LoriotPro MIB database (the MIB tree) and should pertain to the same snmp table object. You can't use oid in doted notation.

Return Values

The function return an array and the number of row in this array. A maximum of 15 rows (oid) can be collected by this way.

rownumber: The number of row in the array

Return nil if an error occurs

arrayname : Provide an array of all the requested SNMP OID.

For each row the arrayname["I-"%i] give the SNMP index of the row.

For each entry in the row the value are retrieved with arrayname["oid-"%i] where %i is the line number.
Example: arrayname["ifspeed-"..i] provide the array column "ifspeed" with row number i from the array called arrayname.

Return nil if an error occurs

Example

lp_value = lp.GetRows(lp_host,"ifoutoctets.0,ifspeed,ifdescr","a");
if lp_value ~= nil then
lp.Trace(("return "..lp_value.." lines"));
for i=0 , (lp_value-1) do
lp.Trace("line "..i.." with index "..a["I-"..i]);
lp.Trace(a["ifdescr-"..i].."/"..a["ifspeed-"..i].."/".."ifoutoctets("..a["ifoutoctets-"..i]..")");
end
lp_buffer="ok";
else
lp_buffer="error";
end

Remark: The string concatenation in LUA is denoted by two dots ("a".."b") = "ab"

The exemple below demonstrate the execution for this script on Windows system with one network interface.



www.loriotpro.com