Skip to content

Commit

Permalink
Merge branch 'pmrepconf-vs-filesys-type'
Browse files Browse the repository at this point in the history
  • Loading branch information
natoscott committed Mar 4, 2024
2 parents 7be77e5 + 980bd54 commit 280f8f0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pmlogconf/pmrepconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,23 @@ name_compare(const void *p, const void *q)
return strcmp(*pp, *qq);
}

static void
name_rewrite(char *in, char *out, size_t outsz)
{
char *ip, *op;

/* Metrics ending in keywords (like 'filesys.type') are problematic */
for (ip = in, op = out; *ip != '\0' && op - out < outsz-2; ip++, op++)
*op = (*ip == '.') ? '_' : *ip;
out[ip - in] = '\0';
}

static void
pmrep_metrics(FILE *f)
{
unsigned int i;
char *s;
char buffer[BUFSIZ];

/* cleanup metric lines, removing comments, whitespace */
for (i = 0; i < nmetrics; i++) {
Expand All @@ -194,7 +206,8 @@ pmrep_metrics(FILE *f)
continue;
if (i > 0 && strcmp(metrics[i], metrics[i-1]) == 0)
continue; /* skip duplicates */
fprintf(f, "%s = %s\n", metrics[i], metrics[i]);
name_rewrite(metrics[i], buffer, sizeof(buffer));
fprintf(f, "%s = %s\n", buffer, metrics[i]);
}
fputs("\n", f);
}
Expand Down

0 comments on commit 280f8f0

Please sign in to comment.