mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-04 09:50:09 +00:00
Refactors user_scripts into checks (lua)
This commit is contained in:
parent
3c3aa5a25f
commit
76fd315d1b
222 changed files with 980 additions and 981 deletions
|
|
@ -15,8 +15,8 @@ local global_state = nil
|
|||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category, see user_scripts.script_categories for all available categories
|
||||
category = user_scripts.script_categories.other,
|
||||
-- Script category, see checks.script_categories for all available categories
|
||||
category = checks.script_categories.other,
|
||||
|
||||
-- This module is enabled by default
|
||||
default_enabled = true,
|
||||
|
|
@ -161,7 +161,7 @@ function script.hooks.min(info)
|
|||
local bytes = host.getBytes()
|
||||
local tot_bytes = bytes["bytes.sent"] + bytes["bytes.rcvd"]
|
||||
|
||||
if(tot_bytes > info.user_script_config.max_bytes) then
|
||||
if(tot_bytes > info.check_config.max_bytes) then
|
||||
-- Trigger alert
|
||||
alerts_api.trigger(info.alert_entity, alert_info)
|
||||
else
|
||||
|
|
@ -15,8 +15,8 @@ local global_state = nil
|
|||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category, see user_scripts.script_categories for all available categories
|
||||
category = user_scripts.script_categories.other,
|
||||
-- Script category, see checks.script_categories for all available categories
|
||||
category = checks.script_categories.other,
|
||||
|
||||
-- This module is enabled by default
|
||||
default_enabled = true,
|
||||
|
|
@ -92,7 +92,7 @@ function script.hooks.min(info)
|
|||
-- Calculate the delta bytes wrt the previous hook run
|
||||
bytes_delta = alerts_api.interface_delta_val(script.key, info.granularity, info.entity_info["ndpi"]["HTTP"]["bytes.sent"])
|
||||
|
||||
if(bytes_delta > info.user_script_config.max_sent_http_bytes) then
|
||||
if(bytes_delta > info.check_config.max_sent_http_bytes) then
|
||||
exceeded = true
|
||||
end
|
||||
end
|
||||
|
|
@ -15,8 +15,8 @@ local global_state = nil
|
|||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category, see user_scripts.script_categories for all available categories
|
||||
category = user_scripts.script_categories.other,
|
||||
-- Script category, see checks.script_categories for all available categories
|
||||
category = checks.script_categories.other,
|
||||
|
||||
-- This module is enabled by default
|
||||
default_enabled = true,
|
||||
|
|
@ -96,7 +96,7 @@ function script.hooks.min(info)
|
|||
},
|
||||
}
|
||||
|
||||
if(inner_bytes > info.user_script_config.max_inner_bytes) then
|
||||
if(inner_bytes > info.check_config.max_inner_bytes) then
|
||||
-- Trigger alert
|
||||
alerts_api.trigger(info.alert_entity, alert_info)
|
||||
else
|
||||
|
|
@ -17,8 +17,8 @@ local global_state = nil
|
|||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category, see user_scripts.script_categories for all available categories
|
||||
category = user_scripts.script_categories.other,
|
||||
-- Script category, see checks.script_categories for all available categories
|
||||
category = checks.script_categories.other,
|
||||
|
||||
-- This module is enabled by default
|
||||
default_enabled = true,
|
||||
|
|
@ -15,8 +15,8 @@ local global_state = nil
|
|||
-- #################################################################
|
||||
|
||||
local script = {
|
||||
-- Script category, see user_scripts.script_categories for all available categories
|
||||
category = user_scripts.script_categories.other,
|
||||
-- Script category, see checks.script_categories for all available categories
|
||||
category = checks.script_categories.other,
|
||||
|
||||
-- This module is enabled by default
|
||||
default_enabled = true,
|
||||
|
|
@ -85,7 +85,7 @@ function script.hooks.min(info)
|
|||
--tprint(info)
|
||||
print("system:min hook called")
|
||||
|
||||
ntop.pingHost(info.user_script_config.ip_address, info.user_script_config.v6)
|
||||
ntop.pingHost(info.check_config.ip_address, info.check_config.v6)
|
||||
|
||||
-- Wait results
|
||||
ntop.msleep(2000)
|
||||
|
|
@ -95,7 +95,7 @@ function script.hooks.min(info)
|
|||
-- The alert entity must be built manually for system scripts
|
||||
local alert_entity = {
|
||||
alert_entity = alert_consts.alert_entities.am_host,
|
||||
alert_entity_val = info.user_script_config.ip_address,
|
||||
alert_entity_val = info.check_config.ip_address,
|
||||
}
|
||||
|
||||
local alert_info = {
|
||||
|
|
@ -105,13 +105,13 @@ function script.hooks.min(info)
|
|||
alert_type_params = {},
|
||||
}
|
||||
|
||||
if(res[info.user_script_config.ip_address] ~= nil) then
|
||||
print(string.format("Host %s is active", info.user_script_config.ip_address))
|
||||
if(res[info.check_config.ip_address] ~= nil) then
|
||||
print(string.format("Host %s is active", info.check_config.ip_address))
|
||||
|
||||
-- Release previously triggered alert (if any)
|
||||
alerts_api.release(alert_entity, alert_info)
|
||||
else
|
||||
print(string.format("Host %s is down", info.user_script_config.ip_address))
|
||||
print(string.format("Host %s is down", info.check_config.ip_address))
|
||||
|
||||
-- Trigger alert
|
||||
alerts_api.trigger(alert_entity, alert_info)
|
||||
Loading…
Add table
Add a link
Reference in a new issue