![]() |
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.
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
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")
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
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.
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
![]() |
|