Fixes link error by adding new interface alert (#5711) and fixes top sites segv

This commit is contained in:
MatteoBiscosi 2021-08-13 13:10:45 +02:00
parent f10dd6a6d0
commit 8a359b8897
8 changed files with 88 additions and 19 deletions

View file

@ -430,25 +430,28 @@ end
function alert_utils.getConfigsetAlertLink(alert_json, alert --[[ optional --]])
local info = alert_json.alert_generation or (alert_json.alert_info and alert_json.alert_info.alert_generation)
if(info and isAdministrator()) then
if alert then
-- This piece of code (exception) has been moved here from formatAlertMessage
if(alert_consts.getAlertType(alert.alert_id, alert.entity_id) == "alert_am_threshold_cross") then
local plugins_utils = require "plugins_utils"
local active_monitoring_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
local host = json.decode(alert.json)["host"]
-- This piece of code (exception) has been moved here from formatAlertMessage
if(alert_consts.getAlertType(alert.alert_id, alert.entity_id) == "alert_am_threshold_cross") then
local plugins_utils = require "plugins_utils"
local active_monitoring_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
local host = json.decode(alert.json)["host"]
if host and host.measurement and not host.is_infrastructure then
return ' <a href="'.. ntop.getHttpPrefix() ..'/plugins/active_monitoring_stats.lua?am_host='
.. host.host .. '&measurement='.. host.measurement ..'&page=overview"><i class="fas fa-cog" title="'.. i18n("edit_configuration") ..'"></i></a>'
end
end
if host and host.measurement and not host.is_infrastructure then
return ' <a href="'.. ntop.getHttpPrefix() ..'/plugins/active_monitoring_stats.lua?am_host='
.. host.host .. '&measurement='.. host.measurement ..'&page=overview"><i class="fas fa-cog" title="'.. i18n("edit_configuration") ..'"></i></a>'
end
end
end
return(' <a href="'..alert_utils.getConfigsetURL(info.script_key, info.subdir)..'">'..
'<i class="fas fa-cog" title="'.. i18n("edit_configuration") ..'"></i></a>')
elseif isAdministrator() then
return (' <a href="' .. ntop.getHttpPrefix() .. '/lua/admin/edit_configset.lua?subdir=interface#all">'..
'<i class="fas fa-cog" title="'.. i18n("edit_configuration") ..'"></i></a>')
end
return('')