Delete old timeseries when monitoring granularity is changed

This commit is contained in:
emanuele-f 2020-04-15 10:52:38 +02:00
parent 8fb749400b
commit 4bd04e7e4c
6 changed files with 53 additions and 33 deletions

View file

@ -189,6 +189,7 @@ if(page == "overview") then
<li>]] .. i18n("active_monitoring_stats.rtt_note_icmp") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.rtt_note_http") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.note_alert") ..[[</li>
<li>]] .. i18n("active_monitoring_stats.note_periodiciy_change") ..[[</li>
</ul>
</div>
<span class="invalid-feedback"></span>

View file

@ -99,6 +99,7 @@ elseif(action == "edit") then
local url = active_monitoring_utils.formatRttHost(host, measurement)
local old_rtt_host = _POST["old_rtt_host"]
local old_measurement = _POST["old_measurement"]
local old_granularity = _POST["old_granularity"]
if(isValidHostMeasurementCombination(host, measurement) == false) then
-- NOTE: reportError already called
@ -115,6 +116,11 @@ elseif(action == "edit") then
return
end
if isEmptyString(old_granularity) then
reportError(i18n("missing_x_parameter", {param='old_granularity'}))
return
end
local old_url = active_monitoring_utils.formatRttHost(old_rtt_host, old_measurement)
existing = active_monitoring_utils.hasHost(old_rtt_host, old_measurement)
@ -133,10 +139,15 @@ elseif(action == "edit") then
return
end
active_monitoring_utils.deleteHost(old_rtt_host, old_measurement)
active_monitoring_utils.deleteHost(old_rtt_host, old_measurement) -- also calls discardHostTimeseries
active_monitoring_utils.addHost(host, measurement, rtt_value, granularity)
else
-- The key is the same, only update the rtt
-- The key is the same, only update the rtt/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)
end