From 2977414d540c9cb78baa3d7fc612fcb4d6ecc72f Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 30 Oct 2021 10:57:14 +0200 Subject: [PATCH] Discard stale information from DiskIO and NetworkIO meters This ensures the initial read of the data is not misinterpreted as arbitrarily large values. Also this forces the maximum update interval between two subsequent reads to within 30s. Fixes #860 --- DiskIOMeter.c | 6 ++++++ NetworkIOMeter.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/DiskIOMeter.c b/DiskIOMeter.c index c5f14768..11fb791e 100644 --- a/DiskIOMeter.c +++ b/DiskIOMeter.c @@ -81,6 +81,12 @@ static void DiskIOMeter_updateValues(Meter* this) { cached_msTimeSpend_total = data.totalMsTimeSpend; } + if (passedTimeInMs > 30000) { + // Triggers for the first initialization and + // when there was a long time we did not collect updates + hasData = false; + } + this->values[0] = cached_utilisation_diff; this->total = MAXIMUM(this->values[0], 100.0); /* fix total after (initial) spike */ diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c index dcba78de..6c429c32 100644 --- a/NetworkIOMeter.c +++ b/NetworkIOMeter.c @@ -85,6 +85,12 @@ static void NetworkIOMeter_updateValues(Meter* this) { cached_txp_total = data.packetsTransmitted; } + if (passedTimeInMs > 30000) { + // Triggers for the first initialization and + // when there was a long time we did not collect updates + hasData = false; + } + this->values[0] = cached_rxb_diff; this->values[1] = cached_txb_diff; if (cached_rxb_diff + cached_txb_diff > this->total) {