-
- for (i = 0; i < ncpus; i++) {
- if (unlikely(getsysctl("kern.cp_times", pcpu_cp_time, sizeof(cp_time) * ncpus))) {
- do_cpu_cores = 0;
- error("DISABLED: cpu.cpuXX");
- break;
- }
- if (unlikely(ncpus > 9999)) {
- error("FREEBSD: There are more than 4 digits in cpu cores number");
- do_cpu_cores = 0;
- error("DISABLED: cpu.cpuXX");
- break;
- }
- snprintfz(cpuid, 8, "cpu%d", i);
-
- st = rrdset_find_bytype("cpu", cpuid);
- if (unlikely(!st)) {
- st = rrdset_create("cpu", cpuid, NULL, "utilization", "cpu.cpu", "Core utilization", "percentage", 1000, update_every, RRDSET_TYPE_STACKED);
-
- rrddim_add(st, "user", NULL, 1, 1, RRDDIM_PCENT_OVER_DIFF_TOTAL);
- rrddim_add(st, "nice", NULL, 1, 1, RRDDIM_PCENT_OVER_DIFF_TOTAL);
- rrddim_add(st, "system", NULL, 1, 1, RRDDIM_PCENT_OVER_DIFF_TOTAL);
- rrddim_add(st, "interrupt", NULL, 1, 1, RRDDIM_PCENT_OVER_DIFF_TOTAL);
- rrddim_add(st, "idle", NULL, 1, 1, RRDDIM_PCENT_OVER_DIFF_TOTAL);
- rrddim_hide(st, "idle");
- }
- else rrdset_next(st);
-
- rrddim_set(st, "user", pcpu_cp_time[i * 5 + 0]);
- rrddim_set(st, "nice", pcpu_cp_time[i * 5 + 1]);
- rrddim_set(st, "system", pcpu_cp_time[i * 5 + 2]);
- rrddim_set(st, "interrupt", pcpu_cp_time[i * 5 + 3]);
- rrddim_set(st, "idle", pcpu_cp_time[i * 5 + 4]);
- rrdset_done(st);
+ if (unlikely(getsysctl("kern.cp_times", pcpu_cp_time, sizeof(cp_time) * ncpus))) {
+ do_cpu_cores = 0;
+ error("DISABLED: cpu.cpuXX");
+ } else {
+ for (i = 0; i < ncpus; i++) {
+ snprintfz(cpuid, MAX_INT_DIGITS, "cpu%d", i);
+ st = rrdset_find_bytype_localhost("cpu", cpuid);
+ if (unlikely(!st)) {
+ st = rrdset_create_localhost("cpu", cpuid, NULL, "utilization", "cpu.cpu", "Core utilization",
+ "percentage", 1000, update_every, RRDSET_TYPE_STACKED);
+
+ rrddim_add(st, "nice", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
+ rrddim_add(st, "system", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
+ rrddim_add(st, "user", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
+ rrddim_add(st, "interrupt", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
+ rrddim_add(st, "idle", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
+ rrddim_hide(st, "idle");
+ } else
+ rrdset_next(st);
+
+ rrddim_set(st, "nice", pcpu_cp_time[i * 5 + 1]);
+ rrddim_set(st, "system", pcpu_cp_time[i * 5 + 2]);
+ rrddim_set(st, "user", pcpu_cp_time[i * 5 + 0]);
+ rrddim_set(st, "interrupt", pcpu_cp_time[i * 5 + 3]);
+ rrddim_set(st, "idle", pcpu_cp_time[i * 5 + 4]);
+ rrdset_done(st);
+ }