Implement ntopng plugins

Plugins are a convenient way to group together related lua scripts.
Their primary use case is to group user scripts and their alert/status
definition.
The builtin ntopng user scripts and definitions are now
packed into plugins directories. In future, we will support loading of
user created plugins.
Plugins are loaded at startup into some runtime directories and then
used. Other changes provided by this commit include:

- Add sample flow logger plugin
- Initial support for system user scripts
- Rename edge to threshold
- Migrate system probes to user scripts/plugins
- Migrate scripts to more explicit alerts_api.checkThresholdAlert api
This commit is contained in:
emanuele-f 2019-12-04 11:34:18 +01:00
parent df245fad3a
commit a3432e00e8
218 changed files with 2070 additions and 2097 deletions

View file

@ -0,0 +1,39 @@
--
-- (C) 2019 - ntop.org
--
local alerts_api = require("alerts_api")
local alert_consts = require("alert_consts")
local script
-- #################################################################
local function check_ghost_networks(params)
for domain, domain_info in pairs(params.entity_info.bcast_domains or {}) do
if(domain_info.ghost_network) then
local key = params.user_script.key .. "__" .. domain
local delta_hits = alerts_api.interface_delta_val(key, params.granularity, domain_info.hits)
local ghost_network_type = alerts_api.ghostNetworkType(domain, params.granularity)
if(delta_hits > 0) then
alerts_api.trigger(params.alert_entity, ghost_network_type, nil, params.cur_alerts)
else
alerts_api.release(params.alert_entity, ghost_network_type, nil, params.cur_alerts)
end
end
end
end
-- #################################################################
script = {
default_enabled = true,
hooks = {
min = check_ghost_networks,
},
}
-- #################################################################
return script