Cleanup remaining references to RTT

This commit is contained in:
emanuele-f 2020-04-20 12:21:39 +02:00
parent 241a0bc2e8
commit 0be2da4f57
26 changed files with 253 additions and 254 deletions

View file

@ -89,7 +89,7 @@ page_utils.print_navbar(title, url,
label = "<i class='fas fa-lg fa-chart-area'></i>",
},
{
hidden = not isAdministrator() or not plugins_utils.hasAlerts(getSystemInterfaceId(), {entity = alert_consts.alertEntity("pinged_host")}),
hidden = not isAdministrator() or not plugins_utils.hasAlerts(getSystemInterfaceId(), {entity = alert_consts.alertEntity("am_host")}),
active = page == "alerts",
page_name = "alerts",
label = "<i class=\"fas fa-lg fa-exclamation-triangle\"></i>",
@ -127,7 +127,7 @@ if(page == "overview") then
<div class='container-fluid my-3'>
<div class='row'>
<div class="col-md-12">
<div id="rtt-alert" class="alert alert-success" style="display: none" role="alert">
<div id="am-alert" class="alert alert-success" style="display: none" role="alert">
<strong>]] .. i18n("success") .. [[</strong> <span class="alert-body"></span>
<button type="button" class="close" aria-label="Close">
<span aria-hidden="true">&times;</span>
@ -137,7 +137,7 @@ if(page == "overview") then
</div>
<div class='row'>
<div class='col-md-12 col-12'>
<table class="table w-100 table-striped table-hover table-bordered" id="rtt-table">
<table class="table w-100 table-striped table-hover table-bordered" id="am-table">
<thead>
<tr>
<th>]].. i18n("flow_details.url") ..[[</th>
@ -156,8 +156,8 @@ if(page == "overview") then
</div>
</div>
<div id='rtt-edit-modal' class="modal fade" tabindex="-1" role="dialog">
<form method="post" id='rtt-edit-form'>
<div id='am-edit-modal' class="modal fade" tabindex="-1" role="dialog">
<form method="post" id='am-edit-form'>
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
@ -200,8 +200,8 @@ if(page == "overview") then
<div id='script-description' class='alert alert-light' role='alert'>
]] .. i18n("notes") ..[[
<ul>
<li>]] .. i18n("active_monitoring_stats.rtt_note_icmp") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.rtt_note_http") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.am_note_icmp") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.am_note_http") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.note_alert") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.note_periodicity_change") ..[[</li>
</ul>
@ -218,8 +218,8 @@ if(page == "overview") then
</form>
</div>
<div id='rtt-add-modal' class="modal fade" tabindex="-1" role="dialog">
<form method="post" id='rtt-add-form'>
<div id='am-add-modal' class="modal fade" tabindex="-1" role="dialog">
<form method="post" id='am-add-form'>
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
@ -262,8 +262,8 @@ if(page == "overview") then
<div id='script-description' class='alert alert-light' role='alert'>
]] .. i18n("notes") ..[[
<ul>
<li>]] .. i18n("active_monitoring_stats.rtt_note_icmp") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.rtt_note_http") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.am_note_icmp") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.am_note_http") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.note_alert") ..[[</li>
</ul>
</div>
@ -278,8 +278,8 @@ if(page == "overview") then
</form>
</div>
<div id='rtt-delete-modal' class="modal fade" tabindex="-1" role="dialog">
<form id='rtt-delete-form'>
<div id='am-delete-modal' class="modal fade" tabindex="-1" role="dialog">
<form id='am-delete-form'>
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
@ -296,7 +296,7 @@ if(page == "overview") then
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">]] .. i18n("cancel") .. [[</button>
<button id="btn-delete-rtt" type="submit" class="btn btn-danger">]] .. i18n("delete") .. [[</button>
<button id="btn-delete-am" type="submit" class="btn btn-danger">]] .. i18n("delete") .. [[</button>
</div>
</div>
</div>
@ -324,7 +324,7 @@ if(page == "overview") then
local measurements_info = {}
-- This information is required in rtt-utils.js in order to properly
-- This information is required in active_monitoring_utils.js in order to properly
-- render the template
for key, info in pairs(active_monitoring_utils.getMeasurementsInfo()) do
measurements_info[key] = {
@ -348,7 +348,7 @@ if(page == "overview") then
i18n.expired_csrf = "]] .. i18n("expired_csrf") .. [[";
let get_host = "]].. (_GET["host"] ~= nil and _GET["host"] or "") ..[[";
let rtt_csrf = "]].. ntop.getRandomCSRFValue() ..[[";
let am_csrf = "]].. ntop.getRandomCSRFValue() ..[[";
let import_csrf = "]].. ntop.getRandomCSRFValue() ..[[";
let measurements_info = ]] .. json.encode(measurements_info) .. [[;
@ -360,7 +360,7 @@ if(page == "overview") then
elseif((page == "historical") and (host ~= nil) and (measurement_info ~= nil)) then
local suffix = "_" .. host.granularity
local schema = _GET["ts_schema"] or ("am_host:value" .. suffix)
local schema = _GET["ts_schema"] or ("am_host:val" .. suffix)
local selected_epoch = _GET["epoch"] or ""
local tags = {ifid=getSystemInterfaceId(), host=host.host, measure=host.measurement --[[ note: measurement is a reserved InfluxDB keyword ]]}
local am_ts_label
@ -370,6 +370,7 @@ elseif((page == "historical") and (host ~= nil) and (measurement_info ~= nil)) t
if measurement_info.i18n_am_ts_label then
am_ts_label = i18n(measurement_info.i18n_am_ts_label) or measurement_info.i18n_am_ts_label
else
-- Fallback
am_ts_label = i18n("graphs.num_ms_rtt")
end
@ -382,7 +383,7 @@ elseif((page == "historical") and (host ~= nil) and (measurement_info ~= nil)) t
url = url.."&page=historical"
local timeseries = {
{ schema="am_host:value" .. suffix, label=am_ts_label,
{ schema="am_host:val" .. suffix, label=am_ts_label,
value_formatter=(measurement_info.value_js_formatter or "fmillis"),
metrics_labels={am_metric_label},
},
@ -413,10 +414,10 @@ elseif((page == "alerts") and isAdministrator()) then
interface.select(getSystemInterfaceId())
_GET["ifid"] = getSystemInterfaceId()
_GET["entity"] = alert_consts.alertEntity("pinged_host")
_GET["entity"] = alert_consts.alertEntity("am_host")
if host then
_GET["entity_val"] = active_monitoring_utils.getRttHostKey(host.host, host.measurement)
_GET["entity_val"] = active_monitoring_utils.getAmHostKey(host.host, host.measurement)
end
alert_utils.drawAlerts()

View file

@ -74,9 +74,9 @@ end
if(action == "add") then
local existing
local rtt_value = _POST["rtt_max"]
local am_value = _POST["threshold"]
local granularity = _POST["granularity"]
local url = active_monitoring_utils.formatRttHost(host, measurement)
local url = active_monitoring_utils.formatAmHost(host, measurement)
if(isValidHostMeasurementCombination(host, measurement) == false) then
-- NOTE: reportError already called
@ -90,14 +90,14 @@ if(action == "add") then
return
end
active_monitoring_utils.addHost(host, measurement, rtt_value, granularity)
active_monitoring_utils.addHost(host, measurement, am_value, granularity)
rv.message = i18n("active_monitoring_stats.host_add_ok", {host=url})
elseif(action == "edit") then
local existing
local rtt_value = _POST["rtt_max"]
local am_value = _POST["threshold"]
local granularity = _POST["granularity"]
local url = active_monitoring_utils.formatRttHost(host, measurement)
local old_rtt_host = _POST["old_rtt_host"]
local url = active_monitoring_utils.formatAmHost(host, measurement)
local old_am_host = _POST["old_am_host"]
local old_measurement = _POST["old_measurement"]
local old_granularity = _POST["old_granularity"]
@ -106,8 +106,8 @@ elseif(action == "edit") then
return
end
if isEmptyString(old_rtt_host) then
reportError(i18n("missing_x_parameter", {param='old_rtt_host'}))
if isEmptyString(old_am_host) then
reportError(i18n("missing_x_parameter", {param='old_am_host'}))
return
end
@ -121,16 +121,16 @@ elseif(action == "edit") then
return
end
local old_url = active_monitoring_utils.formatRttHost(old_rtt_host, old_measurement)
local old_url = active_monitoring_utils.formatAmHost(old_am_host, old_measurement)
existing = active_monitoring_utils.hasHost(old_rtt_host, old_measurement)
existing = active_monitoring_utils.hasHost(old_am_host, old_measurement)
if not existing then
reportError(i18n("active_monitoring_stats.host_not_exists", {host=old_url}))
return
end
if((old_rtt_host ~= host) or (old_measurement ~= measurement)) then
if((old_am_host ~= host) or (old_measurement ~= measurement)) then
-- The key has changed, delete the old host and create a new one
existing = active_monitoring_utils.hasHost(host, measurement)
@ -139,21 +139,21 @@ elseif(action == "edit") then
return
end
active_monitoring_utils.deleteHost(old_rtt_host, old_measurement) -- also calls discardHostTimeseries
active_monitoring_utils.addHost(host, measurement, rtt_value, granularity)
active_monitoring_utils.deleteHost(old_am_host, old_measurement) -- also calls discardHostTimeseries
active_monitoring_utils.addHost(host, measurement, am_value, granularity)
else
-- The key is the same, only update the rtt/granularity
-- The key is the same, only update the value/granularity
if(old_granularity ~= granularity) then
-- Need to discard the old timeseries as the granularity has changed
active_monitoring_utils.discardHostTimeseries(host, measurement)
end
active_monitoring_utils.addHost(host, measurement, rtt_value, granularity)
active_monitoring_utils.addHost(host, measurement, am_value, granularity)
end
rv.message = i18n("active_monitoring_stats.host_edit_ok", {host=old_url})
elseif(action == "delete") then
local url = active_monitoring_utils.formatRttHost(host, measurement)
local url = active_monitoring_utils.formatAmHost(host, measurement)
local existing = active_monitoring_utils.hasHost(host, measurement)
if not existing then

View file

@ -35,8 +35,8 @@ for key, active_monitoring_host in pairs(active_monitoring_hosts) do
local column_last_ip = ""
local column_last_update = ""
local column_last_rtt = ""
local last_update = active_monitoring_utils.getLastRttUpdate(active_monitoring_host.host, active_monitoring_host.measurement)
local column_last_value = ""
local last_update = active_monitoring_utils.getLastAmUpdate(active_monitoring_host.host, active_monitoring_host.measurement)
local alerted = 0
if(last_update ~= nil) then
@ -48,20 +48,24 @@ for key, active_monitoring_host in pairs(active_monitoring_hosts) do
column_last_update = format_utils.formatPastEpochShort(last_update.when)
end
column_last_rtt = last_update.value
column_last_value = last_update.value
column_last_ip = last_update.ip
end
if(column_last_rtt == "") then chart = "" end
column_last_value = tonumber(column_last_value)
if(m_info.operator == "gt") then
if(column_last_rtt > active_monitoring_host.max_rtt) then
alerted = 1
end
if(column_last_value == nil) then
chart = ""
else
if(column_last_rtt < active_monitoring_host.max_rtt) then
alerted = 1
end
if(m_info.operator == "gt") then
if(column_last_value > active_monitoring_host.threshold) then
alerted = 1
end
else
if(column_last_value < active_monitoring_host.threshold) then
alerted = 1
end
end
end
res[#res + 1] = {
@ -71,8 +75,8 @@ for key, active_monitoring_host in pairs(active_monitoring_hosts) do
alerted = alerted,
measurement = active_monitoring_host.measurement,
chart = chart,
threshold = active_monitoring_host.max_rtt,
last_measure = column_last_rtt,
threshold = active_monitoring_host.threshold,
last_measure = column_last_value or "",
value_js_formatter = m_info.value_js_formatter,
last_mesurement_time = column_last_update,
last_ip = column_last_ip,

View file

@ -50,7 +50,7 @@ active_monitoring_utils.resetConfig()
for host_key, conf in pairs(data) do
host = active_monitoring_utils.key2host(host_key)
active_monitoring_utils.addHost(host.host, host.measurement, conf.max_rtt, conf.granularity)
active_monitoring_utils.addHost(host.host, host.measurement, conf.threshold, conf.granularity)
end
-- ################################################