From bb91d9c88061629ee6bce5c7a09d0d3b7d324d32 Mon Sep 17 00:00:00 2001 From: Sebastien GODARD Date: Sat, 6 Apr 2019 10:04:36 +0200 Subject: [PATCH] sadf: PCP: Fix CPU metrics definition CPU#1 is not necessarily selected by the user when PCP archive is created. So don't use it to define per-cpu metrics. Signed-off-by: Sebastien GODARD --- pcp_def_metrics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pcp_def_metrics.c b/pcp_def_metrics.c index 3959f37..04a0e36 100644 --- a/pcp_def_metrics.c +++ b/pcp_def_metrics.c @@ -40,7 +40,7 @@ void pcp_def_cpu_metrics(struct activity *a) { #ifdef HAVE_PCP - int i; + int i, first = TRUE; char buf[64]; pmInDom indom; @@ -98,7 +98,7 @@ void pcp_def_cpu_metrics(struct activity *a) pmiUnits(0, 0, 0, 0, 0, 0)); } else { - if (i == 1) { + if (first) { indom = pmInDom_build(0, PM_INDOM_CPU); pmiAddMetric("kernel.percpu.cpu.user", @@ -140,6 +140,7 @@ void pcp_def_cpu_metrics(struct activity *a) pmiAddMetric("kernel.percpu.cpu.guest_nice", PM_IN_NULL, PM_TYPE_FLOAT, indom, PM_SEM_INSTANT, pmiUnits(0, 0, 0, 0, 0, 0)); + first = FALSE; } sprintf(buf, "cpu%d", i - 1); pmiAddInstance(indom, buf, i - 1); -- 2.40.0