prevent parsing per core metrics when per core cpu collection is disabled
Costa Tsaousis (ktsaou) committed
Sep 5, 2017 at 21:55 UTC
5ce92a893246fd02f84460121243267c2253f5e2
1 file changed
+30
-29
src/proc_stat.c
+30
-29
@@ -66,38 +66,39 @@ int do_proc_stat(int update_every, usec_t dt) {
66
continue;
67
}
68
69
- char *id;
70
- unsigned long long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
71
-
69
size_t core = (row_key[3] == '\0') ? 0 : str2ul(&row_key[3]) + 1;
73
- id = row_key;
74
- user = str2ull(procfile_lineword(ff, l, 1));
75
- nice = str2ull(procfile_lineword(ff, l, 2));
76
- system = str2ull(procfile_lineword(ff, l, 3));
77
- idle = str2ull(procfile_lineword(ff, l, 4));
78
- iowait = str2ull(procfile_lineword(ff, l, 5));
79
- irq = str2ull(procfile_lineword(ff, l, 6));
80
- softirq = str2ull(procfile_lineword(ff, l, 7));
81
- steal = str2ull(procfile_lineword(ff, l, 8));
82
-
83
- guest = str2ull(procfile_lineword(ff, l, 9));
84
- user -= guest;
85
-
86
- guest_nice = str2ull(procfile_lineword(ff, l, 10));
87
- nice -= guest_nice;
88
-
89
- char *title, *type, *context, *family;
90
- long priority;
91
-
92
- if(core >= all_cpu_charts_size) {
93
- size_t old_cpu_charts_size = all_cpu_charts_size;
94
- all_cpu_charts_size = core + 1;
95
- all_cpu_charts = reallocz(all_cpu_charts, sizeof(struct cpu_chart) * all_cpu_charts_size);
96
- memset(&all_cpu_charts[old_cpu_charts_size], 0, sizeof(struct cpu_chart) * (all_cpu_charts_size - old_cpu_charts_size));
97
- }
98
- struct cpu_chart *cpu_chart = &all_cpu_charts[core];
70
71
if(likely((core == 0 && do_cpu) || (core > 0 && do_cpu_cores))) {
72
+ char *id;
73
+ unsigned long long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
74
+
75
+ id = row_key;
76
+ user = str2ull(procfile_lineword(ff, l, 1));
77
+ nice = str2ull(procfile_lineword(ff, l, 2));
78
+ system = str2ull(procfile_lineword(ff, l, 3));
79
+ idle = str2ull(procfile_lineword(ff, l, 4));
80
+ iowait = str2ull(procfile_lineword(ff, l, 5));
81
+ irq = str2ull(procfile_lineword(ff, l, 6));
82
+ softirq = str2ull(procfile_lineword(ff, l, 7));
83
+ steal = str2ull(procfile_lineword(ff, l, 8));
84
+
85
+ guest = str2ull(procfile_lineword(ff, l, 9));
86
+ user -= guest;
87
+
88
+ guest_nice = str2ull(procfile_lineword(ff, l, 10));
89
+ nice -= guest_nice;
90
+
91
+ char *title, *type, *context, *family;
92
+ long priority;
93
+
94
+ if(core >= all_cpu_charts_size) {
95
+ size_t old_cpu_charts_size = all_cpu_charts_size;
96
+ all_cpu_charts_size = core + 1;
97
+ all_cpu_charts = reallocz(all_cpu_charts, sizeof(struct cpu_chart) * all_cpu_charts_size);
98
+ memset(&all_cpu_charts[old_cpu_charts_size], 0, sizeof(struct cpu_chart) * (all_cpu_charts_size - old_cpu_charts_size));
99
+ }
100
+ struct cpu_chart *cpu_chart = &all_cpu_charts[core];
101
+
102
if(unlikely(!cpu_chart->st)) {
103
if(core == 0) {
104
title = "Total CPU utilization";