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

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.GetEventList(‘array’);

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

Description

The lp.GetEventList LUA function returns in a table the list of all referenced action associated to an events of LoriotPro

Parameters

‘array’              An emtpy array that will contain the returned parameters

index             Equal to 1 if the table start at 1, require to support the LUA ipairs(array) function.

Return Values

Number         The number of entries in the table 'array’

Warning ! . LoriotPro LUA function returns indexed table starting at index 0. Usually LUA function returns table starting at index 1. This cas cause errors when using some management function of LUA.

array[0]…array[number-1]             An array of the IP adresses of the devices found. (or array[1]…array[number] if index)

nil                            nil if an error occurs

Example

Simple browse of the event list

lp.Print("start\n");

number=lp.GetEvenList("ta");

if number then

lp.Print(string.format("\nFound %i Loriot Event registered\n",number));

 

for j=0,(number-1) do

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

end

 

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

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

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

end

 

lp.Print("ipairs\n");

lp.GetEvenList("ta",1);

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

 

end

The following example uses the function related to event management within LoriotPro. It displays the list of event and all the values that can be used by a script.

number=lp.GetEvenList("ta");

 

if number then

lp.Print(string.format("\nFound %i Loriot Event registered\n",number));

for j=0,(number-1) do

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

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

--lp.AckEvent(ta[j]);

 

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

      lp.Print(string.format("Loriot Event : %d \t%s\n",ta[j],inf.description));

      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.GetEventActionList(ta[j],"taa");

 

if number2 then

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

 

for jj=0,(number2-1) do

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

 

--lp.AckEventFilterAction(taa[jj]);

 

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

      lp.Print(string.format("\tref \t%s ",infi.ref));

     lp.Print(string.format("\tip \t%s mask \t %s\n",infi.ip,infi.mask));

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

      elseif infi.action_type==64 then

            lp.Print(" ACTIONTYPE_TRAP");

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

      elseif infi.action_type==70 then

            lp.Print(" ACTIONTYPE_EVENT_CORRELATOR");

      elseif infi.action_type==71 then

            lp.Print(" ACTIONTYPE_EVENT_SCRIPTER");

      elseif infi.action_type==72 then

            lp.Print(" ACTIONTYPE_EVENT_TTS");

      elseif infi.action_type==73 then

            lp.Print(" ACTIONTYPE_EVENT_SMS");

      elseif infi.action_type==74 then

            lp.Print(" ACTIONTYPE_EVENT_DELAY");

      elseif infi.action_type==75 then

            lp.Print(" ACTIONTYPE_EVENT_ACK_DELAYED");

      end

 

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

 

 

    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

The following example displays the events that have an associated filter in the filter tree.  The list of all events is located in the file bin/config/events.txt .

File below bin/config/events.txt

#Events reference number to name LoriotPro

#Dont modify this file, use the Internal LoriotPro tools

50000 "New host" 4294967295 0

78000 "test" 4294967295 0

300000 "test trap filter and display" 3 0

5556 "Process Surveyor : A process is missing" 4294967295 0

5555 "Process Surveyor : a new process is running" 4294967295 0

10007 "Arrêt dervice Symantec" 4294967295 0

10006 "Clé mensura déconnectée" 4294967295 0

10013 "Espace Disque Faible" 4294967295 0

10005 "Température salle Serveur élevée" 4294967295 0

10004 "ALERTE - Arrêt d'une base de données (Processus)" 4294967295 0

10001 "ALERTE Arrêt d'un service réseau" 4294967295 0

10010 "Service TCP Polling v1.0" 4294967295 0

10012 "Service SmtpEventScheduler v1.0" 4294967295 0

10011 "Service URL Link Polling v1.0" 4294967295 0

600 "Audit Module Information" 4294967295 0

501 "Service Event Scripter Locked" 4294967295 0

500 "Thread Create fail" 4294967295 0

401 "LoriotPro HTTP HTTP Server Authentication fail" 4294967295 0

400 "LoriotPro HTTP Server IP Access-list deny" 4294967295 0

300 "Trap/Notification Event" 4294967295 0

250 "SnmpV3 Report packet" 4294967295 0

223 "Service Pluging Deleted" 4294967295 0

222 "File handle Watchdog : all open file closed" 4294967295 0

221 "Trap Socket Watchdog : deamon restarted" 4294967295 0

220 "Event Socket Watchdog : deamon restarted" 4294967295 0

219 "Poller Watchdog for 127.0.0.1 level 4" 4294967295 0

218 "Poller Watchdog for 127.0.0.1 level 3" 4294967295 0

217 "Kernel GetTableEntry Buffer overflow" 4294967295 0

216 "Service Plug-in loaded" 4294967295 0

215 "Service Plug-in Loading error" 4294967295 0

214 "SNMP V3 Error" 4294967295 0

213 "SNMP V3 Replay" 4294967295 0

212 "SNMP V3 Authentication Error" 4294967295 0

211 "LoriotPro Shutdown" 4294967295 0

210 "LoriotPro Wake Up" 4294967295 0

209 "Plug-in loaded" 4294967295 0

208 "Plug-in Loading Error" 4294967295 0

207 "SNMP Polling Stopped" 4294967295 0

206 "SNMP Polling Started" 4294967295 0

205 "Ping Polling Stopped" 4294967295 0

204 "Ping Polling Started" 4294967295 0

203 "LoriotPro Polling Process Stopped" 4294967295 0

202 "LoriotPro Polling Process Started" 4294967295 0

201 "LoriotPro HTTP Server Stopped" 4294967295 0

200 "LoriotPro HTTP Server Started" 4294967295 0

103 "Host Polling Stopped" 4294967295 0

102 "Host Polling Started" 4294967295 0

101 "Host not responding to LoriotPro Polling" 4294967295 0

100 "Host responding to LoriotPro Polling" 4294967295 0

51 "Dynamic DNS name to IP Adresse already used" 4294967295 0

50 "Dynamic DNS name to IP Adresse change" 4294967295 0

8 "Directory Tree Item Deleted" 4294967295 0

7 "New Directory  Tree" 4294967295 0

6 "Append Tree" 4294967295 0

5 "Load Tree" 4294967295 0

2 "New network" 4294967295 0

1 "New host" 4294967295 0

10002 "ALERTE - Agent de sauvegarde manquant" 4294967295 0

10003 "ALERTE - Service DNS et/ou WINS hors-service" 4294967295 0

566666 "New host" 4294967295 0

67001 "loriot critique" 4294967295 0

The structure of an event is quite simple 

Event_number  « description »  max_display  status 

Field

Description

Event_number

The number that uniquely indetify this event

“description”

The description of the event between double quote

Max_display

The number of event to display in the real time log viewer of LoriotPro: 

4294967295 ou -1 = no limit 

other = The limit is defined in the event parameters

0 à 2147483647

status

0 = actif
1 = inactif

 

get event list with lua

 The filter tree shows only the events that have at least one associated filter. The script provides all the events even those without filter.

Extrait du résultat 

Found 61 Loriot Event registered

Event Reference 50000

Loriot Event : 50000       New host

       last 0

       first 0

       first_since 0

        number_total 0

        number_ack 0

        number_delete 0

        number_auto_delete 0

        number_since_clear 0

        number_not_displayed 0

        number_displayed 0

        max_display -1

        number_between_action 0

        max_action 0

        number_between_action 0

Event Reference 78000

Loriot Event : 78000       test

       last 1202043069

       first 1202043067

       first_since 1202043067

        number_total 3

        number_ack 0

        number_delete 0

        number_auto_delete 0

        number_since_clear 3

        number_not_displayed 0

        number_displayed 3

        max_display -1

        number_between_action 0

        max_action 0

        number_between_action 0

 

Found 2 filter/Action registered for this event

 

       Ack Action UID [5048075397443354657] for  78000

       ref    78000 ip     0.0.0.0 mask  0.0.0.0

       Search string value 0 [(null)] condition [1]

       Search string value 1 [(null)] condition [0]

       action_type 32  ACTIONTYPE_SYSLOG string [<134> %m]

       counter 3

       last 1202043069

       first 1202043067

       first_since 1202043067

        number_total 3

        number_ack 0

        number_delete 0

        number_auto_delete 0

        number_since_clear 3

        number_not_displayed 0

        number_displayed 0

        max_display -1

        number_between_action 0

        max_action -1

        number_between_action 0

        action_threshold 0

        action_mode 0

        in_time 0

        clock 0

       Ack Action UID [5156866558273781802] for  78000

       ref    78000 ip     127.0.0.1 mask       255.255.255.255

       Search string value 0 [(null)] condition [1]

       Search string value 1 [(null)] condition [0]

       action_type 71  ACTIONTYPE_EVENT_SCRIPTER      string [testeventfilter myparam1]

       counter 3

       last 1202043069

       first 1202043067

       first_since 1202043067

        number_total 3

        number_ack 0

        number_delete 0

        number_auto_delete 0

        number_since_clear 3

        number_not_displayed 0

        number_displayed 0

        max_display -1

        number_between_action 0

        max_action -1

        number_between_action 0

        action_threshold 0

        action_mode 0

        in_time 0

        clock 0

 

 


www.loriotpro.com