ntopng/scripts/callbacks/interface/flow/external_alert_check.lua
emanuele-f 9b5be79b1d Remove redundant script key
The script file name is used as the key
2019-10-31 18:24:58 +01:00

39 lines
1 KiB
Lua

--
-- (C) 2019 - ntop.org
--
local flow_consts = require("flow_consts")
local json = require ("dkjson")
local user_scripts = require ("user_scripts")
-- #################################################################
local script = {
-- NOTE: hooks defined below
hooks = {},
gui = {
i18n_title = "flow_callbacks_config.ext_alert",
i18n_description = "flow_callbacks_config.ext_alert_description",
input_builder = user_scripts.flow_checkbox_input_builder,
}
}
-- #################################################################
function script.hooks.periodicUpdate(params)
local ext_alert_info = flow.retrieveExternalAlertInfo()
if ext_alert_info ~= nil then
-- NOTE: the same info will *not* be returned in the next periodicUpdate
local info = json.decode(ext_alert_info)
if info ~= nil then
flow.triggerStatus(flow_consts.status_types.status_external_alert.status_id,
info, info.severity_id)
end
end
end
-- #################################################################
return script