Skip to content

Commit

Permalink
cockpit: send now along with the internalmetrics meta
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jelly authored and martinpitt committed Dec 11, 2024
1 parent 2d6af15 commit 35090b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/playground/plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<body class="pf-v5-m-tabular-nums">
<div id="plot-direct"></div>
<div id="plot-pmcd"></div>
<div id="plot-internal"></div>
</body>
</html>
12 changes: 12 additions & 0 deletions pkg/playground/plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
<SvgPlot className="mem-graph"
title="Internal" config={bytes_config}
plot_state={plot_state} plot_id="internal" />
);
});
4 changes: 3 additions & 1 deletion src/cockpit/channels/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions test/verify/check-pages
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 35090b7

Please sign in to comment.