@cryptotaxi247 / netdata-1 / commits / 2e88104dd

slabinfo: Handle slabs added after discovery (#11257)

Adrien Mahieux committed Jun 17, 2021 at 09:53 UTC 2e88104ddc4c2bf3a365c87d463b62c659635a49
1 file changed +8 -1
collectors/slabinfo.plugin/slabinfo.c
+8 -1
@@ -51,6 +51,8 @@ char *netdata_configured_host_prefix = "";
51
52 int running = 1;
53 int debug = 0;
54 +size_t lines_discovered = 0;
55 +int redraw_chart = 0;
56
57 // ----------------------------------------------------------------------------
58
@@ -187,6 +189,10 @@ struct slabinfo *read_file_slabinfo() {
189
190 // Iterate on all lines to populate / update the slabinfo struct
191 size_t lines = procfile_lines(ff), l;
192 + if (unlikely(lines != lines_discovered)) {
193 + lines_discovered = lines;
194 + redraw_chart = 1;
195 + }
196
197 slabdebug(" Read %lu lines from procfile", (unsigned long)lines);
198 for(l = 2; l < lines; l++) {
@@ -254,7 +260,8 @@ unsigned int do_slab_stats(int update_every) {
260 sactive = read_file_slabinfo();
261
262 // Init Charts
257 - if (unlikely(loops == 0)) {
263 + if (unlikely(redraw_chart)) {
264 + redraw_chart = 0;
265 // Memory Usage
266 printf("CHART %s.%s '' 'Memory Usage' 'B' '%s' '' line %d %d %s\n"
267 , CHART_TYPE