mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Add support for a custom user defined alert endpoint script
This commit is contained in:
parent
a784ccaf60
commit
2f47b4a87e
3 changed files with 66 additions and 5 deletions
42
scripts/lua/modules/alert_endpoints/sample.lua
Normal file
42
scripts/lua/modules/alert_endpoints/sample.lua
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
--
|
||||
-- (C) 2018 - ntop.org
|
||||
--
|
||||
|
||||
require "lua_utils"
|
||||
local json = require "dkjson"
|
||||
|
||||
local script = {}
|
||||
|
||||
-- How often this script will be called (in seconds)
|
||||
script.EXPORT_FREQUENCY = 5
|
||||
|
||||
-- The minimum severity for an alert
|
||||
script.DEFAULT_SEVERITY = "warning"
|
||||
|
||||
function script.dequeueAlerts(queue)
|
||||
while true do
|
||||
local json_alert = ntop.lpopCache(queue)
|
||||
|
||||
if not json_alert then
|
||||
break
|
||||
end
|
||||
|
||||
local alert = json.decode(json_alert)
|
||||
|
||||
-- Print the alert on the console
|
||||
tprint(alert)
|
||||
|
||||
if (alert.action == "engage") then
|
||||
if (alertTypeRaw(alert.type) == "threshold_cross") and
|
||||
(alert.alert_key == "min_active_local_hosts") then
|
||||
|
||||
-- Run a custom bash script
|
||||
--os.execute("/tmp/my_script.sh")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {success=true}
|
||||
end
|
||||
|
||||
return script
|
||||
Loading…
Add table
Add a link
Reference in a new issue