]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
cpu plugin: Use the `cpu_num` field in `usage_t`.
authorFlorian Forster <octo@collectd.org>
Tue, 9 Jan 2024 12:06:31 +0000 (13:06 +0100)
committerFlorian Forster <octo@collectd.org>
Mon, 22 Jan 2024 15:07:57 +0000 (16:07 +0100)
src/cpu.c

index a044f25ad268f2bd8972b71d7546cbece6f7d5e1..23ef10ca5926d3cd2fe5153d2d7b1070d22835fa 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -215,10 +215,6 @@ static int pnumcpu;
       (sum) += (val);                                                          \
   } while (0)
 
-/* Highest CPU number in the current iteration. Used by the dispatch logic to
- * determine how many CPUs there were. Reset to 0 by cpu_reset(). */
-static size_t global_cpu_num;
-
 static bool report_by_cpu = true;
 static bool report_by_state = true;
 static bool report_usage = true;
@@ -659,8 +655,8 @@ static void commit_usage(usage_t *u) {
     return;
   }
 
-  for (size_t cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) {
-    commit_cpu_usage(u, cpu_num);
+  for (size_t cpu = 0; cpu < u->cpu_num; cpu++) {
+    commit_cpu_usage(u, cpu);
   }
 }
 
@@ -714,8 +710,8 @@ static void commit_utilization(usage_t *u) {
     return;
   }
 
-  for (size_t cpu_num = 0; cpu_num < global_cpu_num; cpu_num++) {
-    commit_cpu_utilization(u, cpu_num);
+  for (size_t cpu = 0; cpu < u->cpu_num; cpu++) {
+    commit_cpu_utilization(u, cpu);
   }
 }
 
@@ -723,7 +719,7 @@ static void commit_utilization(usage_t *u) {
 static void cpu_commit(usage_t *u) /* {{{ */
 {
   if (report_num_cpu) {
-    cpu_commit_num_cpu((gauge_t)global_cpu_num);
+    cpu_commit_num_cpu((gauge_t)u->cpu_num);
   }
 
   if (report_usage) {