ntopng/scripts/callbacks/syslog.lua
emanuele-f 0d48bff069 Implement more flexible user_scripts api
NOTE: The existing alerts configuration of the users will be discarded.

Some code has been added to make the current gui on/off toggle work.
It is marked with the following comment:

-- TODO remove after implementing the new gui
2019-11-28 11:06:14 +01:00

41 lines
1.1 KiB
Lua

--
-- (C) 2019 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
require "lua_utils"
local user_scripts = require("user_scripts")
local syslog_modules = nil
-- #################################################################
-- The function below ia called once (#pragma once)
function setup()
syslog_modules = user_scripts.load(interface.getId(), user_scripts.script_types.syslog, ".")
end
-- #################################################################
-- The function below is called for each received alert
function handleEvent(name, message)
local event_handler = syslog_modules.hooks["handleEvent"][name]
if(event_handler ~= nil) then
event_handler(message)
end
end
-- #################################################################
-- The function below ia called once (#pragma once)
function teardown()
for mod_name, syslog_module in pairs(syslog_modules) do
if syslog_module.teardown ~= nil then
syslog_module.teardown()
end
end
end
-- #################################################################