mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-28 23:19:33 +00:00
Moved notification formatting function (#7781)
This commit is contained in:
parent
ba330e8e0d
commit
144de3a7e6
9 changed files with 75 additions and 35 deletions
|
|
@ -454,6 +454,34 @@ function format_utils.formatHostNameAndAddress(hostname, address)
|
|||
|
||||
return res
|
||||
end
|
||||
|
||||
-- ######################################################
|
||||
|
||||
-- This is a basic function used to format notifications
|
||||
local function format_notification(notification, options)
|
||||
local message = notification.message or ""
|
||||
-- TODO: add the support to options
|
||||
return message
|
||||
end
|
||||
|
||||
-- ######################################################
|
||||
|
||||
-- This function is used to format alerts/message from recipients
|
||||
-- so it's going to convert a table into a message delivered to the
|
||||
-- various recipients.
|
||||
-- Currently there are two types of messages, alerts and notifications
|
||||
function format_utils.formatMessage(notification, options)
|
||||
if not notification.score or notification.score == 0 then
|
||||
-- In case it is just a message/report (so no score), format like a normal msg
|
||||
return format_notification(notification, options)
|
||||
else
|
||||
-- In case it is an alert, format it by using the standard function
|
||||
local alert_utils = require "alert_utils"
|
||||
return alert_utils.formatAlertNotification(notification, options)
|
||||
end
|
||||
end
|
||||
|
||||
-- ######################################################
|
||||
|
||||
if(trace_script_duration ~= nil) then
|
||||
io.write(debug.getinfo(1,'S').source .." executed in ".. (os.clock()-clock_start)*1000 .. " ms\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue