mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 10:41:34 +00:00
* Add lowerbound and percentage threshold on host rules. (#6855) * Add interface rules. (#6855) * Added ability to blacklist hosts via Lua API * Not supposed to be committed * Method signature change to be called it also from a lua host script * Fix empty string heck * Add param check * Add example listing alerts * Fix params check * Fix alert raw queris * Removed debug code * MacOS changes * Updated (C) * Warning fixes * Removed sprintf calls * Added rx_only_hosts classification * https://github.com/ntop/ntopng/issues/7233; extend datatable component to allow external vue components in table menu bar * Update dist: https://github.com/ntop/ntopng/issues/7233; extend datatable component to allow external vue components in table menu bar * Remove obsoleted comment * Minor GUI fix. (#6855) * Fix on alert format. (#6855) * Minor fix. (#6855) * Update doc. (#6855) --------- Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com> Co-authored-by: Luca Deri <deri@ntop.org> Co-authored-by: Alfredo Cardigliano <cardigliano@ntop.org> Co-authored-by: uccidibuti <vannucci@ntop.org>
This commit is contained in:
parent
9618eee614
commit
cf8a89a7e1
15 changed files with 389 additions and 164 deletions
|
|
@ -0,0 +1,91 @@
|
|||
--
|
||||
-- (C) 2019-22 - ntop.org
|
||||
--
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local other_alert_keys = require "other_alert_keys"
|
||||
|
||||
-- Import the classes library.
|
||||
local classes = require "classes"
|
||||
-- Make sure to import the Superclass!
|
||||
local alert = require "alert"
|
||||
local alert_entities = require "alert_entities"
|
||||
local format_utils = require "format_utils"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local alert_network_rule_threshold_cross = classes.class(alert)
|
||||
|
||||
alert_network_rule_threshold_cross.meta = {
|
||||
alert_key = other_alert_keys.alert_network_rule_threshold_cross,
|
||||
i18n_title = "show_alerts.network_interface_rule_threshold_cross",
|
||||
icon = "fas fa-fw fa-exclamation-triangle",
|
||||
entities = {
|
||||
alert_entities.system,
|
||||
alert_entities.interface,
|
||||
},
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function alert_network_rule_threshold_cross:init(ifid, ifname ,metric, frequency, threshold, value, threshold_sign, metric_type)
|
||||
-- Call the parent constructor
|
||||
self.super:init()
|
||||
|
||||
self.alert_type_params = {
|
||||
ifid = ifid,
|
||||
ifname = ifname,
|
||||
metric = metric,
|
||||
frequency = frequency,
|
||||
threshold = threshold,
|
||||
value = value,
|
||||
threshold_sign = threshold_sign,
|
||||
metric_type = metric_type
|
||||
}
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
-- @brief Format an alert into a human-readable string
|
||||
-- @param ifid The integer interface id of the generated alert
|
||||
-- @param alert The alert description table, including alert data such as the generating entity, timestamp, granularity, type
|
||||
-- @param alert_type_params Table `alert_type_params` as built in the `:init` method
|
||||
-- @return A human-readable string
|
||||
function alert_network_rule_threshold_cross.format(ifid, alert, alert_type_params)
|
||||
|
||||
if(alert_type_params.frequency == "5min") then
|
||||
alert_type_params.frequency = i18n("edit_check.hooks_name.5mins")
|
||||
elseif(alert_type_params.frequency == "hour") then
|
||||
alert_type_params.frequency = i18n("edit_check.hooks_name.hour")
|
||||
else
|
||||
alert_type_params.frequency = i18n("edit_check.hooks_name.day")
|
||||
end
|
||||
|
||||
if(alert_type_params.metric == "iface:traffic") then
|
||||
if(alert_type_params.metric_type == "volume") then
|
||||
alert_type_params.value = bytesToSize(alert_type_params.value)
|
||||
alert_type_params.threshold = bytesToSize(alert_type_params.threshold)
|
||||
elseif(alert_type_params.metric_type == "throughput") then
|
||||
alert_type_params.value = bitsToSize(alert_type_params.value)
|
||||
alert_type_params.threshold = bitsToSize(alert_type_params.threshold)
|
||||
else
|
||||
alert_type_params.value = string.format("%s",tostring(round(alert_type_params.value, 2))) .. "%"
|
||||
alert_type_params.threshold = string.format("%s",tostring(alert_type_params.threshold)).. "%"
|
||||
end
|
||||
end
|
||||
|
||||
return(i18n("alert_messages.traffic_interface_volume_alert", {
|
||||
url = ntop.getHttpPrefix() .. "/lua/if_stats.lua?ifid=" .. alert_type_params.ifid,
|
||||
iface = alert_type_params.ifname,
|
||||
metric = alert_type_params.metric,
|
||||
value = alert_type_params.value,
|
||||
threshold_sign = alert_type_params.threshold_sign,
|
||||
threshold = alert_type_params.threshold,
|
||||
frequency = alert_type_params.frequency
|
||||
}))
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return alert_network_rule_threshold_cross
|
||||
|
|
@ -94,6 +94,7 @@ local other_alert_keys = {
|
|||
alert_snmp_device_traffic_change = OTHER_BASE_KEY + 81,
|
||||
alert_local_host_blacklisted = OTHER_BASE_KEY + 82,
|
||||
alert_network_issues = OTHER_BASE_KEY + 83,
|
||||
alert_network_rule_threshold_cross = OTHER_BASE_KEY + 84,
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
|
|
|||
|
|
@ -1852,6 +1852,8 @@ local known_parameters = {
|
|||
["rule_id"] = validateSingleWord,
|
||||
["extra_metric"] = validateSingleWord,
|
||||
["rule_type"] = validateSingleWord,
|
||||
["rule_threshold_sign"] = validateNumber,
|
||||
["is_ifname"] = validateBool,
|
||||
|
||||
["bytes"] = validateListOfTypeInline(validateFilters(validateNumber)),
|
||||
["packets"] = validateListOfTypeInline(validateFilters(validateNumber)),
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ page_utils.menu_entries = {
|
|||
countries = {key = "countries", i18n_title = "countries", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/web_gui/hosts.html?#countries"},
|
||||
operating_systems = {key = "operating_systems", i18n_title = "operating_systems", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/web_gui/hosts.html?#operating-systems"},
|
||||
http_servers = {key = "http_servers", i18n_title = "http_servers_stats.local_http_servers", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/web_gui/hosts.html?#http-servers-local"},
|
||||
host_rules = {key = "host_rules", i18n_title = "if_stats_config.host_rules", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/advanced_features/host_rules.html"},
|
||||
top_hosts = {key = "top_hosts", i18n_title = "processes_stats.top_hosts", section = "hosts", help_link = "https://www.ntop.org/guides/ntopng/web_gui/hosts.html?#top-hosts-local"},
|
||||
hosts_treemap = {key = "hosts_treemap", i18n_title = "tree_map.hosts_treemap", section = "hosts"},
|
||||
containers = {key = "containers", i18n_title = "containers_stats.containers", section = "hosts"},
|
||||
|
|
@ -108,7 +107,8 @@ page_utils.menu_entries = {
|
|||
-- Interface
|
||||
interface = {key = "interface", i18n_title = "interface_details", section = "if_stats"},
|
||||
ports_analysis = {key = "ports_analysis", i18n_title = "ports_analysis.server_ports", section = "if_stats"},
|
||||
|
||||
host_rules = {key = "host_rules", i18n_title = "if_stats_config.traffic_rules", section = "if_stats", help_link = "https://www.ntop.org/guides/ntopng/advanced_features/host_rules.html"},
|
||||
|
||||
-- Pollers
|
||||
snmp = {key = "snmp", i18n_title = "prefs.snmp", section = "pollers"},
|
||||
infrastructure_dashboard = {key = "infrastructure_dashboard", i18n_title = "infrastructure_dashboard.infrastructure_dashboard", section = "pollers"},
|
||||
|
|
|
|||
|
|
@ -651,31 +651,60 @@ end
|
|||
|
||||
-- #################################
|
||||
|
||||
function timeseries_info.get_host_rules_schema()
|
||||
local host_ts_enabled = ntop.getCache("ntopng.prefs.host_ndpi_timeseries_creation")
|
||||
local has_top_protocols = host_ts_enabled == "both" or host_ts_enabled == "per_protocol" or host_ts_enabled ~= "0"
|
||||
local has_top_categories = host_ts_enabled == "both" or host_ts_enabled == "per_category"
|
||||
function timeseries_info.get_host_rules_schema(is_interface)
|
||||
if not is_interface then
|
||||
local host_ts_enabled = ntop.getCache("ntopng.prefs.host_ndpi_timeseries_creation")
|
||||
local has_top_protocols = host_ts_enabled == "both" or host_ts_enabled == "per_protocol" or host_ts_enabled ~= "0"
|
||||
local has_top_categories = host_ts_enabled == "both" or host_ts_enabled == "per_category"
|
||||
|
||||
local metric_list = {
|
||||
{ title = i18n('traffic'), group = i18n('generic_data'), label = i18n('traffic'), id = 'host:traffic' --[[ here the ID is the schema ]], show_volume = true },
|
||||
{ title = i18n('score'), group = i18n('generic_data'), label = i18n('score'), id = 'host:score' --[[ here the ID is the schema ]], show_volume = false },
|
||||
}
|
||||
local metric_list = {
|
||||
{ title = i18n('traffic'), group = i18n('generic_data'), label = i18n('traffic'), id = 'host:traffic' --[[ here the ID is the schema ]], show_volume = true },
|
||||
{ title = i18n('score'), group = i18n('generic_data'), label = i18n('score'), id = 'host:score' --[[ here the ID is the schema ]], show_volume = false },
|
||||
}
|
||||
|
||||
if has_top_protocols then
|
||||
local application_list = interface.getnDPIProtocols()
|
||||
for application, _ in pairsByKeys(application_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = application, group = i18n('applications_long'), title = application, id = 'top:host:ndpi', extra_metric = 'protocol:' .. application --[[ here the schema is the ID ]], show_volume = true }
|
||||
if has_top_protocols then
|
||||
local application_list = interface.getnDPIProtocols()
|
||||
for application, _ in pairsByKeys(application_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = application, group = i18n('applications_long'), title = application, id = 'top:host:ndpi', extra_metric = 'protocol:' .. application --[[ here the schema is the ID ]], show_volume = true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if has_top_categories then
|
||||
local category_list = interface.getnDPICategories()
|
||||
for category, _ in pairsByKeys(category_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = category, group = i18n('categories'), title = category, id = 'top:host:ndpi_categories', extra_metric = 'category:' .. category --[[ here the schema is the ID ]], show_volume = true }
|
||||
if has_top_categories then
|
||||
local category_list = interface.getnDPICategories()
|
||||
for category, _ in pairsByKeys(category_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = category, group = i18n('categories'), title = category, id = 'top:host:ndpi_categories', extra_metric = 'category:' .. category --[[ here the schema is the ID ]], show_volume = true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return metric_list
|
||||
|
||||
return metric_list
|
||||
else
|
||||
local ifname_ts_enabled = ntop.getCache("ntopng.prefs.ifname_ndpi_timeseries_creation")
|
||||
local has_top_protocols = ifname_ts_enabled == "both" or ifname_ts_enabled == "per_protocol" or ifname_ts_enabled ~= "0"
|
||||
local has_top_categories = ifname_ts_enabled == "both" or ifname_ts_enabled == "per_category"
|
||||
|
||||
local metric_list = {
|
||||
{ title = i18n('traffic'), group = i18n('generic_data'), label = i18n('traffic'), id = 'iface:traffic' --[[ here the ID is the schema ]], show_volume = true },
|
||||
{ title = i18n('score'), group = i18n('generic_data'), label = i18n('score'), id = 'iface:score' --[[ here the ID is the schema ]], show_volume = false },
|
||||
}
|
||||
|
||||
if has_top_protocols then
|
||||
local application_list = interface.getnDPIProtocols()
|
||||
for application, _ in pairsByKeys(application_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = application, group = i18n('applications_long'), title = application, id = 'top:iface:ndpi', extra_metric = 'protocol:' .. application --[[ here the schema is the ID ]], show_volume = true }
|
||||
end
|
||||
end
|
||||
|
||||
if has_top_categories then
|
||||
local category_list = interface.getnDPICategories()
|
||||
for category, _ in pairsByKeys(category_list or {}, asc) do
|
||||
metric_list[#metric_list + 1] = { label = category, group = i18n('categories'), title = category, id = 'top:iface:ndpi_categories', extra_metric = 'category:' .. category --[[ here the schema is the ID ]], show_volume = true }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return metric_list
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue