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.GetTableEntryList

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.

Warning  ! The function returns table with ordered index starting at 0. By default in LUA index start at 1. V=Beware of this particularity before using LUA function attached to table broswing.

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");

table snmp in lua table

 

 


www.loriotpro.com