mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-05 19:15:03 +00:00
Implements flow callbacks and alerts in C++
This commit is contained in:
parent
3659188002
commit
aea9138bfb
353 changed files with 10790 additions and 4455 deletions
|
|
@ -1,64 +0,0 @@
|
|||
--
|
||||
-- (C) 2019-21 - ntop.org
|
||||
--
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local alert_keys = require "alert_keys"
|
||||
local status_keys = require "status_keys"
|
||||
-- Import the classes library.
|
||||
local classes = require "classes"
|
||||
-- Make sure to import the Superclass!
|
||||
local alert = require "alert"
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local alert_zero_tcp_window = classes.class(alert)
|
||||
|
||||
-- ##############################################
|
||||
|
||||
alert_zero_tcp_window.meta = {
|
||||
status_key = status_keys.ntopng.status_zero_tcp_window,
|
||||
alert_key = alert_keys.ntopng.alert_zero_tcp_window,
|
||||
i18n_title = "zero_tcp_window.zero_tcp_window_title",
|
||||
icon = "fas fa-arrow-circle-up",
|
||||
}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
-- @brief Prepare an alert table used to generate the alert
|
||||
-- @param one_flow_param The first alert param
|
||||
-- @param another_flow_param The second alert param
|
||||
-- @return A table with the alert built
|
||||
function alert_zero_tcp_window:init(is_client, is_server)
|
||||
-- Call the parent constructor
|
||||
self.super:init()
|
||||
|
||||
self.alert_type_params = {
|
||||
is_client = is_client,
|
||||
is_server = is_server,
|
||||
}
|
||||
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_zero_tcp_window.format(ifid, alert, alert_type_params)
|
||||
if alert_type_params then
|
||||
if alert_type_params.is_client then
|
||||
return i18n("zero_tcp_window.status_zero_tcp_window_description_c2s")
|
||||
elseif alert_type_params.is_server then
|
||||
return i18n("zero_tcp_window.status_zero_tcp_window_description_s2c")
|
||||
end
|
||||
end
|
||||
|
||||
return i18n("zero_tcp_window.status_zero_tcp_window_description")
|
||||
end
|
||||
|
||||
-- #######################################################
|
||||
|
||||
return alert_zero_tcp_window
|
||||
|
|
@ -28,9 +28,6 @@ script = {
|
|||
severity = alert_severities.warning,
|
||||
},
|
||||
|
||||
-- NOTE: hooks defined below
|
||||
hooks = {},
|
||||
|
||||
gui = {
|
||||
i18n_title = "zero_tcp_window.zero_tcp_window_title",
|
||||
i18n_description = "zero_tcp_window.zero_tcp_window_description",
|
||||
|
|
@ -39,45 +36,4 @@ script = {
|
|||
|
||||
-- #################################################################
|
||||
|
||||
local function check_tcp_window(now, conf)
|
||||
local zerowin = flow.isTcpZeroWinAlert()
|
||||
|
||||
if(zerowin.client or zerowin.server) then
|
||||
local high_score = 30
|
||||
local low_score = 5
|
||||
local client_score
|
||||
local server_score
|
||||
|
||||
-- Client -> Server
|
||||
if(zerowin.client) then
|
||||
client_score = high_score
|
||||
server_score = low_score
|
||||
end
|
||||
|
||||
-- Server -> Client
|
||||
if(zerowin.server) then
|
||||
client_score = low_score
|
||||
server_score = high_score
|
||||
end
|
||||
|
||||
local alert = alert_consts.alert_types.alert_zero_tcp_window.new(
|
||||
zerowin.client,
|
||||
zerowin.server
|
||||
)
|
||||
|
||||
alert:set_severity(conf.severity)
|
||||
|
||||
alert:trigger_status(client_score, server_score, high_score)
|
||||
end
|
||||
end
|
||||
|
||||
-- #################################################################
|
||||
|
||||
script.hooks.periodicUpdate = check_tcp_window
|
||||
script.hooks.flowEnd = check_tcp_window
|
||||
|
||||
-- #################################################################
|
||||
|
||||
|
||||
|
||||
return script
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue