From 35090b743b6b4536fc9c09cd9644c1c3b53c1cb2 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Tue, 10 Dec 2024 18:54:40 +0100 Subject: [PATCH] cockpit: send `now` along with the internalmetrics meta The metrics for the networking and storage pages didn't show anything since we switched to the Python implementation. There was no integration test for internalmetrics so this regressed without us noticing as these graphs can also take data from PCP (archive or direct). Fixes: #19627 --- pkg/playground/plot.html | 1 + pkg/playground/plot.js | 12 ++++++++++++ src/cockpit/channels/metrics.py | 4 +++- test/verify/check-pages | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/playground/plot.html b/pkg/playground/plot.html index 45835516f919..39ac967dbcaf 100644 --- a/pkg/playground/plot.html +++ b/pkg/playground/plot.html @@ -11,5 +11,6 @@
+
diff --git a/pkg/playground/plot.js b/pkg/playground/plot.js index 28ed469d9d23..9e645a49165a 100644 --- a/pkg/playground/plot.js +++ b/pkg/playground/plot.js @@ -16,10 +16,16 @@ const pmcd_metric = { units: "bytes" }; +const internal_metric = { + internal: ["memory.used"], + units: "bytes", +}; + document.addEventListener("DOMContentLoaded", function() { const plot_state = new PlotState(); plot_state.plot_single('direct', direct_metric); plot_state.plot_single('pmcd', pmcd_metric); + plot_state.plot_single('internal', internal_metric); // For the tests window.plot_state = plot_state; @@ -35,4 +41,10 @@ document.addEventListener("DOMContentLoaded", function() { title="PMCD" config={bytes_config} plot_state={plot_state} plot_id="pmcd" /> ); + + createRoot(document.getElementById('plot-internal')).render( + + ); }); diff --git a/src/cockpit/channels/metrics.py b/src/cockpit/channels/metrics.py index 2b43a88c4fc2..e977ccc26d48 100644 --- a/src/cockpit/channels/metrics.py +++ b/src/cockpit/channels/metrics.py @@ -107,7 +107,9 @@ def send_meta(self, samples: Samples, timestamp: float): 'semantics': metricinfo.desc.semantics }) - self.send_json(source='internal', interval=self.interval, timestamp=timestamp * 1000, metrics=metrics) + now = int(time.time()) * 1000 + self.send_json(source='internal', interval=self.interval, timestamp=timestamp * 1000, + now=now, metrics=metrics) self.need_meta = False def sample(self) -> Samples: diff --git a/test/verify/check-pages b/test/verify/check-pages index e115e8f8dd64..a66cf19fcdc6 100755 --- a/test/verify/check-pages +++ b/test/verify/check-pages @@ -752,6 +752,12 @@ OnCalendar=daily with b.wait_timeout(60): b.wait_js_func("ph_plot_data_plateau", "pmcd", mem_avail * 0.85, mem_avail * 1.15, 15, "mem") + # Internal metrics only has memory used (memory.used) as a metric not available memory. + meminfo = read_mem_info(m) + mem_avail = meminfo['MemTotal'] - meminfo['MemAvailable'] + with b.wait_timeout(60): + b.wait_js_func("ph_plot_data_plateau", "internal", mem_avail * 0.85, mem_avail * 1.15, 15, "mem") + @testlib.skipBrowser("Headless chromium is missing the synthetic mouseenter", "chromium") def testPageStatus(self): b = self.browser