cgroups: containers-vms add CPU throttling % (#16800)
Ilya Mashchenko committed
Jan 17, 2024 at 16:32 UTC
10de8e0810788f0bf66cf651efab80eb91c85da3
1 file changed
+12
collectors/cgroups.plugin/cgroup-top.c
+12
@@ -112,6 +112,7 @@ int cgroup_function_cgroup_top(BUFFER *wb, const char *function __maybe_unused)
112
113
double max_pids = 0.0;
114
double max_cpu = 0.0;
115
+ double max_cpu_throttled = 0.0;
116
double max_ram = 0.0;
117
double max_disk_io_read = 0.0;
118
double max_disk_io_written = 0.0;
@@ -143,6 +144,9 @@ int cgroup_function_cgroup_top(BUFFER *wb, const char *function __maybe_unused)
144
max_cpu = MAX(max_cpu, cpu);
145
}
146
147
+ double cpu_throttled = (double)cg->cpuacct_cpu_throttling.nr_throttled_perc;
148
+ max_cpu_throttled = MAX(max_cpu_throttled, cpu_throttled);
149
+
150
double ram = rrddim_get_last_stored_value(cg->st_mem_rd_ram, &max_ram, 1.0);
151
152
rd = cg->st_throttle_io_rd_read ? cg->st_throttle_io_rd_read : cg->st_io_rd_read;
@@ -161,6 +165,7 @@ int cgroup_function_cgroup_top(BUFFER *wb, const char *function __maybe_unused)
165
166
buffer_json_add_array_item_double(wb, pids_current);
167
buffer_json_add_array_item_double(wb, cpu);
168
+ buffer_json_add_array_item_double(wb, cpu_throttled);
169
buffer_json_add_array_item_double(wb, ram);
170
buffer_json_add_array_item_double(wb, disk_io_read);
171
buffer_json_add_array_item_double(wb, disk_io_written);
@@ -209,6 +214,13 @@ int cgroup_function_cgroup_top(BUFFER *wb, const char *function __maybe_unused)
214
RRDF_FIELD_OPTS_VISIBLE,
215
NULL);
216
217
+ buffer_rrdf_table_add_field(wb, field_id++, "CPU Throttling", "CPU Throttled Runnable Periods",
218
+ RRDF_FIELD_TYPE_BAR_WITH_INTEGER, RRDF_FIELD_VISUAL_BAR, RRDF_FIELD_TRANSFORM_NUMBER,
219
+ 0, "%", max_cpu_throttled, RRDF_FIELD_SORT_DESCENDING, NULL,
220
+ RRDF_FIELD_SUMMARY_SUM, RRDF_FIELD_FILTER_NONE,
221
+ is_inside_k8s ? RRDF_FIELD_OPTS_VISIBLE : RRDF_FIELD_OPTS_NONE,
222
+ NULL);
223
+
224
// RAM
225
buffer_rrdf_table_add_field(wb, field_id++, "RAM", "RAM Usage",
226
RRDF_FIELD_TYPE_BAR_WITH_INTEGER, RRDF_FIELD_VISUAL_BAR, RRDF_FIELD_TRANSFORM_NUMBER,