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.SendSyslog - Send a Syslog Message to a syslog server

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.

Refers to the request for comment dor more details about the syslog message format RFC 3164

Syntax

value = lp.SendSyslog('ip_server','buffer');

Description

The lp.SendSyslog LUA function sends a Syslog Message to a syslog server.

Parameters

‘ip_server’          The IP address of the remote syslog sever.

'buffer' The text of the message starting with the priority number between <> sign.

The priority value is calculated by multiplying the Facility value by 8 and adding the Severity value.

Table of Facility Table of Severity

Numerical  Facility     

Code

           0            

kernel messages

           1            

user-level messages

           2            

mail system

           3            

system daemons

           4            

security/authorization messages (note 1)

           5            

messages generated internally by syslogd

           6            

line printer subsystem

           7            

network news subsystem

           8            

UUCP subsystem

           9            

clock daemon (note 2)

          10            

security/authorization messages (note 1)

          11            

FTP daemon

          12            

NTP subsystem

          13            

log audit (note 1)

          14           

 log alert (note 1)

          15            

clock daemon (note 2)

          16            

local use 0  (local0)

          17            

local use 1  (local1)

          18            

local use 2  (local2)

          19            

local use 3  (local3)

          20            

local use 4  (local4)

          21            

local use 5  (local5)

          22            

local use 6  (local6)

          23            

local use 7  (local7)

0 Emergency: system is unusable
1 Alert: action must be taken immediately
2 Critical: critical conditions
3 Error: error conditions
4 Warning: warning conditions
5 Notice: normal but significant condition
6 Informational: informational messages
7 Debug: debug-level messages

Example :

With a Facility type of “local use 0” value 16 and a Severity “Critical” value 2

then : (16*8) + 2 = 130

Syntax : lp.SendSyslog(" 127.0.0.1 ", "<130> texte du message")

syslog priority 130

Return Values

value : equal 1 if sent

Return nil if an error occurs

Example

Example of syslog sent to the local LoriotPro embedded Syslog server (listening on the standard syslog UDP port 514) .

 

for i=0,200 do

a=string.format("<167> test %i",i);

lp.SendSyslog("127.0.0.1",a);

end

syslog send with lu

Other example that generate all the syslog messages possibilities

for facility=0,23 do
   for severity=0,7 do
      priority = (facility*8)+severity
      syslogmessage = string.format("<%i> test %i:%i",priority,facility,severity)
      lp.Trace(syslogmessage,"\n")
      lp.SendSyslog("127.0.0.1",syslogmessage)
   end
end

Result of the script in the Syslog viewer.

All syslog type

Other example that generate all the syslog messages possibilities with texte description

facility={"kernel messages","user-level messages","mail system","system daemons","security/authorization messages (note 1)",
"messages generated internally by syslogd","line printer subsystem","network news subsystem","UUCP subsystem",
"clock daemon (note 2)","security/authorization messages (note 1)","FTP daemon","NTP subsystem","log audit (note 1)",
"log alert (note 1)","clock daemon (note 2)","local use 0 (local0)","local use 1 (local1)","local use 2 (local2)",
"local use 3 (local3)","local use 4 (local4)","local use 5 (local5)","local use 6 (local6)","local use 7 (local7)",}

severity={"Emergency: system is unusable","Alert: action must be taken immediately",
"Critical: critical conditions","Error: error conditions","Warning: warning conditions",
"Notice: normal but significant condition","Informational: informational messages","Debug: debug-level messages"}

for facilityIndex=0,23 do
for severityIndex=0,7 do
priority = (facilityIndex*8)+severityIndex
syslogmessage = "<"..priority.."> \tFacility: "..facility[facilityIndex+1].."\tSeverity: "..severity[severityIndex+1]
lp.Trace(syslogmessage,"\n")
lp.SendSyslog("127.0.0.1",syslogmessage)
end
end

 


www.loriotpro.com