Rework host threshold alerts definition

This commit is contained in:
emanuele-f 2019-07-11 18:15:57 +02:00
parent 328c8a7084
commit b16136f5b4
13 changed files with 125 additions and 124 deletions

View file

@ -8,25 +8,20 @@ local alert_consts = require("alert_consts")
local check_module = {
key = "p2p",
alert_type = alert_consts.alert_types.threshold_cross,
check_function = alerts_api.threshold_check_function,
gui = {
title = "alerts_thresholds_config.p2p_traffic",
subtitle = "alerts_thresholds_config.alert_p2p_description",
field = {field_unit = alert_consts.field_units.bytes},
i18n_title = "alerts_thresholds_config.p2p_traffic",
i18n_description = "alerts_thresholds_config.alert_p2p_description",
i18n_field_unit = alert_consts.field_units.bytes,
input_builder = alerts_api.threshold_cross_input_builder,
}
}
-- #################################################################
function check_module.check_function(granularity, host_key, info, threshold_config)
local p2p_bytes = alerts_api.application_bytes(info, "eDonkey") + alerts_api.application_bytes(info, "BitTorrent") + alerts_api.application_bytes(info, "Skype")
local current_value = alerts_api.host_delta_val(check_module.key, granularity, p2p_bytes)
return(alerts_api.check_threshold_cross(
granularity, check_module.key,
alerts_api.hostAlertEntity(host_key),
current_value, threshold_config
))
function check_module.get_threshold_value(granularity, info)
return alerts_api.host_delta_val(check_module.key, granularity, alerts_api.category_bytes(info, "FileSharing"))
end
-- #################################################################