| LUA scripting documentation |
This library (http://www.cs.princeton.edu/~diego/professional/luasocket/) is a useful example that can be reused to send syslog message to the LoriotPro syslog server (port 516 ).
Example :
--------------------------------------------------------------------------------
-- main programme
--------------------------------------------------------------------------------
dofile(lp.GetPath().."/config/script/compat-5.1.lua");
module("socket");
--local socket = require("socket.core");
lp_buffer="ok";
lp_value=1;
lib2,init=lp.LoadLibrary(lp.GetPath().."/lua_socket.dll","luaopen_socket_core");
if (lib2) then init() end;
if lib2==nil then error("library not loaded \n") end;
lp.Print("Load library (",lp.GetVersion(),")\n");
-- change here to the host an port you want to contact
local host, port = "localhost", 516
-- load namespace
-- convert host name to ip address
local ip = assert(socket.dns.toip(host))
-- create a new UDP object
local udp = assert(socket.udp())
-- contact daytime host
assert(udp:sendto("anything from LUA_socket", ip, port))
-- retrieve the answer and print results
--lp.Print(assert(udp:receive()))
lp.Print("send syslog packet \n");
lp.Print(" End of script\n");

www.loriotpro.com |
|