Skip to content

Commit

Permalink
sadf: PCP: Fix CPU metrics definition
Browse files Browse the repository at this point in the history
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 <sysstat@users.noreply.github.com>
  • Loading branch information
sysstat committed Apr 6, 2019
1 parent 8cfeb32 commit bb91d9c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pcp_def_metrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bb91d9c

Please sign in to comment.