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

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 = lp.GetTrapFilterList(‘array’); 

number = lp.GetTrapFilterList(‘array’,index);

Description

The lp.GetTrapFilterList LUA function retrieve a list of trap that have known filter statistics.

Parameters

‘array’   A table containing the UID of the trap filters.

index    The quantity of indexes of objecst.

Return Values

umber              The total number of trap filters.

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.

‘array’   The table with the UID list                

array[0]..array[number-1]        The UID found (or array[1] … array[number] if index)

nil                           If an error occurs       

Example

A simple example of browsing

number2=lp.GetTrapFilterList("ta"); 

if number2 then

lp.Print(string.format("\nFound %i Action registered for this trap filter\n\n",number2));

for jj=0,(number2-1) do

lp.Print(string.format("\tTrap Action UID [%s] \n",ta[jj]));

end 

lp.Print("table.getn\n");

for i=0,table.getn(ta) do

lp.Print(string.format("Trap Action %s\n",ta[i]));

end 

lp.Print("ipairs\n");

lp.GetTrapFilterList("ta",1);

for key,value in ipairs(ta) do lp.Print("[",key,"] [",value,"]\n") end  

end

get trap filter list uid with lua

A full example of all the functions for filter and trap management.

number=lp.GetTrapFilterList("ta");

 

if number then

lp.Print(string.format("Found %i SNMP Trap registered\n\n",number));

for j=0,(number-1) do

lp.Print("Ack Trap ---------------------------------------------------------------\n");

lp.AckTrapFilter(ta[j]);

lp.Print(string.format("Trap uid %s\n",ta[j]));

      if lp.GetTrapFilterInformation(ta[j],"inf") then

      lp.Print(string.format("Trap \t%s\n",inf.trap));

      lp.Print(string.format("\tTrap V1 Name \t%s\n",inf.name));

      lp.Print(string.format("\tTrap V1 Generic %i Specific %i\n",inf.generic,inf.specific));

      lp.Print(string.format("\tAssocied event number %d\n",inf.eventnumber));

      lp.Print(string.format("\tAssocied string [%s]\n",inf.string));

      lp.Print(string.format("\tStructure controle 0x%X\n",inf.ctrl));

      lp.Print(string.format("\tcounter %d\n",inf.counter));

      lp.Print(string.format("\tuid %s\n",inf.uid));

 

      lp.Print(string.format("\tlast %d\n",inf.last));

      lp.Print(string.format("\tfirst %d\n",inf.first));

      lp.Print(string.format("\tfirst_since %d\n",inf.first_since));

 

      lp.Print(string.format("\t number_total %d\n",inf.number_total));

      lp.Print(string.format("\t number_ack %d\n",inf.number_ack));

      lp.Print(string.format("\t number_delete %d\n",inf.number_delete));

      lp.Print(string.format("\t number_auto_delete %d\n",inf.number_auto_delete));

      lp.Print(string.format("\t number_since_clear %d\n",inf.number_since_clear));

      lp.Print(string.format("\t number_not_displayed %d\n",inf.number_not_displayed));

      lp.Print(string.format("\t number_displayed %d\n",inf.number_displayed));

      lp.Print(string.format("\t max_display %d\n",inf.max_display));

      lp.Print(string.format("\t number_between_action %d\n",inf.number_between_action));

      lp.Print(string.format("\t max_action %d\n",inf.max_action));

      lp.Print(string.format("\t max_display %d\n",inf.max_display));

      lp.Print(string.format("\t number_between_action %d\n",inf.number_between_action));

 

number2=lp.GetTrapFilterActionList(ta[j],"taa");

 

if number2 then

lp.Print(string.format("\nFound %i Action registered for this trap filter\n\n",number2));

for jj=0,(number2-1) do

 

lp.Print(string.format("\tAck Action UID [%s] for  %s %s\n",taa[jj],ta[j],inf.trap));

lp.AckTrapFilterAction(taa[jj]);

      if lp.GetTrapFilterActionInformation(taa[jj],"infi") then

      lp.Print(string.format("\tIf this parameter match : \tip \t%s mask \t %s ",infi.ip,infi.mask));

      lp.Print(string.format("\tcommunity \t%s\n",infi.community));

      lp.Print(string.format("\tSearch string value 0 [%s] condition [%i] \n",infi.search_string0,infi.search_condition0));

      lp.Print(string.format("\tSearch string value 1 [%s] condition [%i] \n",infi.search_string1,infi.search_condition1));

      lp.Print(string.format("\tSearch string value 2 [%s] condition [%i] \n",infi.search_string2,infi.search_condition2));

      lp.Print(string.format("\tSearch string value 3 [%s] condition [%i] \n",infi.search_string3,infi.search_condition3));

      lp.Print(string.format("\tSearch string value 4 [%s] condition [%i] \n",infi.search_string4,infi.search_condition4));

      lp.Print(string.format("\tSearch string value 5 [%s] condition [%i] \n",infi.search_string5,infi.search_condition5));

      lp.Print(string.format("\tSearch string value 6 [%s] condition [%i] \n",infi.search_string6,infi.search_condition6));

      lp.Print(string.format("\tSearch string value 7 [%s] condition [%i] \n",infi.search_string7,infi.search_condition7));

      lp.Print(string.format("\tSearch string value 8 [%s] condition [%i] \n",infi.search_string8,infi.search_condition8));

      lp.Print(string.format("\tSearch string value 9 [%s] condition [%i] \n",infi.search_string9,infi.search_condition9));

 

      lp.Print(string.format("\taction_type %d ",infi.action_type));

 

      if infi.action_type==1 then

            lp.Print(" ACTIONTYPE_WINRUN");

      elseif infi.action_type==2 then

            lp.Print(" ACTIONTYPE_WAVE");

      elseif infi.action_type==4 then

            lp.Print(" ACTIONTYPE_SMTP");

      elseif infi.action_type==8 then

            lp.Print(" ACTIONTYPE_MAPI");

      elseif infi.action_type==16 then

            lp.Print(" ACTIONTYPE_DOSRUN");

      elseif infi.action_type==32 then

            lp.Print(" ACTIONTYPE_SYSLOG\n");

      elseif infi.action_type==64 then

            lp.Print(" ACTIONTYPE_TRAP\n");

      elseif infi.action_type==65 then

            lp.Print(" ACTIONTYPE_CUSTOM");

      elseif infi.action_type==66 then

            lp.Print(" ACTIONTYPE_SEARCH");

      elseif infi.action_type==67 then

            lp.Print(" ACTIONTYPE_NULL");

      elseif infi.action_type==68 then

            lp.Print(" ACTIONTYPE_ROUTE_EVENT");

      elseif infi.action_type==69 then

            lp.Print(" ACTIONTYPE_EVENT");

      end

 

      lp.Print(string.format("\tstring [%s]\n",infi.string));

 

--[[

#define TRAP_FILTER_VALUE_NONE 0

#define TRAP_FILTER_VALUE_CONTAIN_CASE 1

#define TRAP_FILTER_VALUE_CONTAIN_NOCASE 2

#define TRAP_FILTER_VALUE_EGAL_CASE 3

#define TRAP_FILTER_VALUE_EGAL_NOCASE 4

#define TRAP_FILTER_VALUE_SUP 5

#define TRAP_FILTER_VALUE_INF 6

#define TRAP_FILTER_VALUE_DIF 7

#define TRAP_FILTER_VALUE_SUP_EGAL 8

#define TRAP_FILTER_VALUE_INF_EGAL 9

--]]

 

      lp.Print(string.format("\tcounter %d\n",infi.counter));

 

      lp.Print(string.format("\tlast %d\n",infi.last));

      lp.Print(string.format("\tfirst %d\n",infi.first));

      lp.Print(string.format("\tfirst_since %d\n",infi.first_since));

      lp.Print(string.format("\t number_total %d\n",infi.number_total));

      lp.Print(string.format("\t number_ack %d\n",infi.number_ack));

      lp.Print(string.format("\t number_delete %d\n",infi.number_delete));

      lp.Print(string.format("\t number_auto_delete %d\n",infi.number_auto_delete));

      lp.Print(string.format("\t number_since_clear %d\n",infi.number_since_clear));

      lp.Print(string.format("\t number_not_displayed %d\n",infi.number_not_displayed));

      lp.Print(string.format("\t number_displayed %d\n",infi.number_displayed));

      lp.Print(string.format("\t max_display %d\n",infi.max_display));

      lp.Print(string.format("\t number_between_action %d\n",infi.number_between_action));

      lp.Print(string.format("\t max_action %d\n",infi.max_action));

      lp.Print(string.format("\t max_display %d\n",infi.max_display));

      lp.Print(string.format("\t number_between_action %d\n",infi.number_between_action));

      lp.Print(string.format("\t action_threshold %d\n",infi.action_threshold));

      lp.Print(string.format("\t action_mode %d\n",infi.action_mode));

      lp.Print(string.format("\t in_time %d\n",infi.in_time));

     lp.Print(string.format("\t clock %d\n",infi.clock));

 

  

end

end

end

 

 

      end

end

end

 

get trap filter list uid with lua

 

 


www.loriotpro.com