![]() ![]() |
LoriotPro
scripting documentation |
![]() ![]() ![]() |
![]() |
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
number_object,number_index = lp.GetTableEntryList('entryname','array');
Description
The lp.GetTableEntryList LUA function retrieves a full SNMP table object in a LUA table.
Parameters
‘entryname’ The name of the SNMP table object.
‘array’ The name of the table in the LUA script.
Return Values
number_object The quantity of objects in the table.
number_index The quantity of indexes of snmp object.
nil If an error occurs
‘array’ The table of returned values.
The name of the index is built in array[‘I-‘ ..X] where X is the index number.
for j=0,(number_index-1) do
lp.Print("[",array["I-"..j],"]");
end
The name of the object are stored in variables array[X] where X is the number of the columnin the SNMP table.
-- Ici ont construit une requête avec les noms collectés.
hh=’’ ;
for j=0,(number_object-1) do
lp.Print(array[j],"\t");
hh=hh..array[j];
hh=hh..",";
end
Example
We use the function PrintTable to demonstrate the function lp.GetTableEntryList .
function PrintTable(ip,entry)
a,b=lp.GetTableEntryList(entry,"array");
if a then
for j=0,(b-1) do
lp.Print("[",array["I-"..j],"]");
end
lp.Print("\t");
hh="";
for j=0,(a-1) do
lp.Print(array[j],"\t");
hh=hh..array[j];
hh=hh..",";
end
lp.Print("\n");
c,d,e=lp.GetRows(ip,hh,"array2");
if c then
--print line
for j=0,(c-1) do
--lp.Print("[",array2["I-"..j],"]","\t")
--print index
for l=0,(e-1) do
lp.Print("[",array2[string.format("OI-%i-%i",j,l)],"]","\t")
end
--print row value
for k=0,(d-1) do
lp.Print(array2[string.format("%s-%i",array[k],j)],"\t")
end
lp.Print("\n");
end
end
end
end
------ start
PrintTable(lp_host,"ifentry");
![]() |
|