diff --git a/include/AlertsQueue.h b/include/AlertsQueue.h index 7a3660ec36..462c628c34 100644 --- a/include/AlertsQueue.h +++ b/include/AlertsQueue.h @@ -46,6 +46,7 @@ class AlertsQueue { u_int32_t tpa, u_int16_t vlan_id); void pushLoginTrace(const char *user, bool authorized); void pushNfqFlushedAlert(int queue_len, int queue_len_pct, int queue_dropped); + void pushCloudDisconnectionAlert(); }; #endif diff --git a/scripts/locales/en.lua b/scripts/locales/en.lua index d676e23968..099019be11 100644 --- a/scripts/locales/en.lua +++ b/scripts/locales/en.lua @@ -1664,6 +1664,11 @@ local lang = { ["title"] = "Unexpected Servers", }, }, + ["cloud"] = { + ["cloud"] = "Cloud", + ["disconnected"] = "Lost connection with the Cloud", + ["disconnection"] = "Cloud Disconnection", + }, ["conf_backup"] = { ["conf_backup"] = "Backup Configuration", ["conf_restore"] = "Restore Configuration", diff --git a/scripts/lua/modules/alert_definitions/other/alert_cloud_disconnected.lua b/scripts/lua/modules/alert_definitions/other/alert_cloud_disconnected.lua new file mode 100644 index 0000000000..9319f98859 --- /dev/null +++ b/scripts/lua/modules/alert_definitions/other/alert_cloud_disconnected.lua @@ -0,0 +1,53 @@ +-- +-- (C) 2019-24 - 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 alert_cloud_disconnected = classes.class(alert) + +-- ############################################## + +alert_cloud_disconnected.meta = { + alert_key = other_alert_keys.alert_cloud_disconnected, + i18n_title = "cloud.disconnection", + icon = "fas fa-fw fa-cloud", + entities = { + alert_entities.system + }, +} + +-- ############################################## + +-- @brief Prepare an alert table used to generate the alert +-- @return A table with the alert built +function alert_cloud_disconnected:init() + -- Call the parent constructor + self.super:init() + + self.alert_type_params = {} +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_cloud_disconnected.format(ifid, alert, alert_type_params) + return(i18n("cloud.disconnected")) +end + +-- ####################################################### + +return alert_cloud_disconnected diff --git a/scripts/lua/modules/alert_keys/other_alert_keys.lua b/scripts/lua/modules/alert_keys/other_alert_keys.lua index 369e0ff72f..1810ee1d96 100644 --- a/scripts/lua/modules/alert_keys/other_alert_keys.lua +++ b/scripts/lua/modules/alert_keys/other_alert_keys.lua @@ -29,7 +29,7 @@ local other_alert_keys = { alert_mac_ip_association_change = OTHER_BASE_KEY + 16, alert_misbehaving_flows_ratio = OTHER_BASE_KEY + 17, alert_misconfigured_app = OTHER_BASE_KEY + 18, - alert_new_device = OTHER_BASE_KEY + 19, -- No longer used + alert_cloud_disconnected = OTHER_BASE_KEY + 19, alert_nfq_flushed = OTHER_BASE_KEY + 20, alert_none = OTHER_BASE_KEY + 21, -- No longer used alert_periodic_activity_not_executed = OTHER_BASE_KEY + 22, diff --git a/scripts/lua/modules/notifications/recipients.lua b/scripts/lua/modules/notifications/recipients.lua index b3c6d7bd90..5816ba2f87 100644 --- a/scripts/lua/modules/notifications/recipients.lua +++ b/scripts/lua/modules/notifications/recipients.lua @@ -130,6 +130,10 @@ local function processStoreAlertFromQueue(alert) alert.dropped) type_info:set_score_error() + elseif (alert.alert_id == "cloud_disconnected") then + entity_info = alert_entity_builders.systemEntity("cloud") + type_info = alert_consts.alert_types.alert_cloud_disconnected.new() + type_info:set_score_warning() else traceError(TRACE_ERROR, TRACE_CONSOLE, "Unknown alert type " .. (alert.alert_id or "")) end diff --git a/src/AlertsQueue.cpp b/src/AlertsQueue.cpp index 28ae517906..1b11362aa8 100644 --- a/src/AlertsQueue.cpp +++ b/src/AlertsQueue.cpp @@ -207,3 +207,20 @@ void AlertsQueue::pushNfqFlushedAlert(int queue_len, int queue_len_pct, pushAlertJson(tlv, "nfq_flushed", NULL, alert_category_system); } } + +/* **************************************************** */ + +void AlertsQueue::pushCloudDisconnectionAlert() { + ndpi_serializer *tlv; + + if (ntop->getPrefs()->are_alerts_disabled()) return; + + tlv = (ndpi_serializer *)calloc(1, sizeof(ndpi_serializer)); + + if (tlv) { + ndpi_init_serializer_ll(tlv, ndpi_serialization_format_tlv, 64); + + pushAlertJson(tlv, "cloud_disconnected", NULL, alert_category_system); + } +} +