From 009f8942fdc593c1be378f9bf2f69c490141db05 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 22 Oct 2021 15:41:50 +1100 Subject: [PATCH] Fix focus panel chart selection for pcp-dstat Headers slightly changed in pcp-dstat output, and the chart we need to get is called "total usage:idl". Look for this field, or fall back to the old one to support both output formats. Change-Id: Ib9aaf3c18da63cf5acd44ccf6eaff1c5fa68ac12 --- js/dashboard.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/dashboard.js b/js/dashboard.js index 2877329..08f510b 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -437,7 +437,18 @@ function displayFocusGraph(graphs, dmin, dmax) { if ($('#focus').children().length > 0) { return; } - data = getValues(graphs, "total cpu usage", "idl") + + /* original dstat has "total cpu usage" with fields "usr", "idl" ... + * pcp dstat has "total usage" with fields "total usage:usr", "total usage:sys" ... + */ + if (getExists(graphs, "total usage", "total usage:idl")) { + data = getValues(graphs, "total usage", "total usage:idl") + } else if (getExists(graphs, "total cpu usage", "idl")) { + data = getValues(graphs, "total cpu usage", "idl") + } else { + alert("Failed to parse: idle CPU stats not found") + } + if (data) { // Rollback to the first element if not found data = data.map(function(idl) { return {x: idl.x, y: (100 - parseFloat(idl.y)) };}); }