mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Adds min host info to all host-alerts (engaged/released/triggered)
This commit is contained in:
parent
e8159593eb
commit
566babf34c
3 changed files with 34 additions and 4 deletions
|
|
@ -128,6 +128,18 @@ local function addAlertPoolInfo(entity_info, alert_json)
|
|||
end
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--! @brief Adds host information to the alert (only works for host alerts)
|
||||
--! @param alert_json Host info will be placed in key `host_info` of table `alert_json`
|
||||
local function addAlertHostInfo(alert_json)
|
||||
if alert_json then
|
||||
-- Add only minimal information to keep the final result as small as possible
|
||||
alert_json.host_info = host.getMinInfo()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--! @param type_info data returned by one of the type_info building functions
|
||||
|
|
@ -180,7 +192,9 @@ function alerts_api.store(entity_info, type_info, when)
|
|||
addAlertPoolInfo(entity_info, alert_to_store)
|
||||
|
||||
if(entity_info.alert_entity.entity_id == alert_consts.alertEntity("host")) then
|
||||
-- NOTE: for engaged alerts this operation is performed during trigger in C
|
||||
-- NOTE: for engaged alerts this operation is performed during trigger in C
|
||||
host.checkContext(entity_info.alert_entity_val)
|
||||
addAlertHostInfo(alert_to_store)
|
||||
interface.incTotalHostAlerts(entity_info.alert_entity_val, type_info.alert_type.alert_key)
|
||||
end
|
||||
|
||||
|
|
@ -284,6 +298,7 @@ function alerts_api.trigger(entity_info, type_info, when, cur_alerts)
|
|||
if(entity_info.alert_entity.entity_id == alert_consts.alertEntity("host")) then
|
||||
host.checkContext(entity_info.alert_entity_val)
|
||||
triggered = host.storeTriggeredAlert(table.unpack(params))
|
||||
addAlertHostInfo(triggered)
|
||||
elseif(entity_info.alert_entity.entity_id == alert_consts.alertEntity("interface")) then
|
||||
interface.checkContext(entity_info.alert_entity_val)
|
||||
triggered = interface.storeTriggeredAlert(table.unpack(params))
|
||||
|
|
@ -360,6 +375,7 @@ function alerts_api.release(entity_info, type_info, when, cur_alerts)
|
|||
if(entity_info.alert_entity.entity_id == alert_consts.alertEntity("host")) then
|
||||
host.checkContext(entity_info.alert_entity_val)
|
||||
released = host.releaseTriggeredAlert(table.unpack(params))
|
||||
addAlertHostInfo(released)
|
||||
elseif(entity_info.alert_entity.entity_id == alert_consts.alertEntity("interface")) then
|
||||
interface.checkContext(entity_info.alert_entity_val)
|
||||
released = interface.releaseTriggeredAlert(table.unpack(params))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue