mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-06 03:45:26 +00:00
Implements missing download for active monitoring alerts
This commit is contained in:
parent
3ae6564cba
commit
bdd7533bfd
2 changed files with 29 additions and 10 deletions
|
|
@ -85,6 +85,20 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
local RNAME = {
|
||||
ALERT_NAME = { name = "alert_name", export = true},
|
||||
MEASUREMENT = { name = "measurement", export = true},
|
||||
MEASURE_THRESHOLD = { name = "measure_threshold", export = true},
|
||||
MEASURE_VALUE = { name = "measure_value", export = true},
|
||||
MSG = { name = "msg", export = true, elements = {"name", "value", "description"}}
|
||||
}
|
||||
|
||||
function am_alert_store:get_rnames()
|
||||
return RNAME
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
--@brief Convert an alert coming from the DB (value) to a record returned by the REST API
|
||||
function am_alert_store:format_record(value, no_html)
|
||||
local am_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
|
||||
|
|
@ -95,23 +109,23 @@ function am_alert_store:format_record(value, no_html)
|
|||
local msg = alert_utils.formatAlertMessage(ifid, value, alert_info)
|
||||
|
||||
if alert_info.threshold > 0 then
|
||||
record["measure_threshold"] = format_utils.formatValue(alert_info.threshold)
|
||||
record[RNAME.MEASURE_THRESHOLD.name] = format_utils.formatValue(alert_info.threshold)
|
||||
end
|
||||
|
||||
if alert_info.value > 0 then
|
||||
record["measure_value"] = alert_info.value
|
||||
record[RNAME.MEASURE_VALUE.name] = alert_info.value
|
||||
end
|
||||
|
||||
local measurement_info = am_utils.getMeasurementInfo(alert_info.host.measurement)
|
||||
record["measurement"] = i18n(measurement_info.i18n_label)
|
||||
record[RNAME.MEASUREMENT.name] = i18n(measurement_info.i18n_label)
|
||||
|
||||
record["alert_name"] = alert_name
|
||||
record[RNAME.ALERT_NAME.name] = alert_name
|
||||
|
||||
if string.lower(noHtml(msg)) == string.lower(noHtml(alert_name)) then
|
||||
msg = ""
|
||||
end
|
||||
|
||||
record["msg"] = msg
|
||||
record[RNAME.MSG.name] = msg
|
||||
|
||||
return record
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,8 +38,13 @@ for _key,_value in ipairs(alerts or {}) do
|
|||
res[#res + 1] = record
|
||||
end -- for
|
||||
|
||||
rest_utils.extended_answer(rc, {records = res}, {
|
||||
["draw"] = tonumber(_GET["draw"]),
|
||||
["recordsFiltered"] = recordsFiltered,
|
||||
["recordsTotal"] = #res
|
||||
}, format)
|
||||
if no_html then
|
||||
res = am_alert_store:to_csv(res)
|
||||
rest_utils.vanilla_payload_response(rc, res, "text/csv")
|
||||
else
|
||||
rest_utils.extended_answer(rc, {records = res}, {
|
||||
["draw"] = tonumber(_GET["draw"]),
|
||||
["recordsFiltered"] = recordsFiltered,
|
||||
["recordsTotal"] = #res
|
||||
}, format)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue