]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
cpu plugin: Use standard system metric names (OTEP #119)
authorFlorian Forster <octo@collectd.org>
Tue, 5 Dec 2023 10:26:43 +0000 (11:26 +0100)
committerFlorian Forster <octo@collectd.org>
Tue, 5 Dec 2023 10:26:43 +0000 (11:26 +0100)
https://github.com/open-telemetry/oteps/blob/main/text/0119-standard-system-metrics.md

src/cpu.c

index 436d2c55a6d97b3d18f5c5b866c9f38ea06cb052..86f6016ccccfe4ea72f309b74f700e6e227af614 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -442,7 +442,7 @@ static void aggregate(gauge_t *sum_by_state) /* {{{ */
 static void cpu_commit_one(int cpu_num, /* {{{ */
                            gauge_t rates[static COLLECTD_CPU_STATE_MAX]) {
   metric_family_t fam = {
-      .name = "cpu_usage_percent",
+      .name = "system.cpu.utilization",
       .type = METRIC_TYPE_GAUGE,
   };
 
@@ -450,8 +450,8 @@ static void cpu_commit_one(int cpu_num, /* {{{ */
   if (cpu_num == -1) {
     metric_label_set(&m, "cpu", "total");
   } else {
-    char cpu_num_str[16];
-    snprintf(cpu_num_str, sizeof(cpu_num_str), "%d", cpu_num);
+    char cpu_num_str[32];
+    ssnprintf(cpu_num_str, sizeof(cpu_num_str), "%d", cpu_num);
     metric_label_set(&m, "cpu", cpu_num_str);
   }
 
@@ -515,7 +515,7 @@ static void cpu_reset(void) /* {{{ */
 static void cpu_commit_without_aggregation(void) /* {{{ */
 {
   metric_family_t fam = {
-      .name = "cpu_usage_total",
+      .name = "system.cpu.time",
       .type = METRIC_TYPE_COUNTER,
   };