@cryptotaxi247 / netdata-1 / commits / ee0d1c5dd

bcache: read priority_stats once every minute; related to #3762

Costa Tsaousis (ktsaou) committed May 29, 2018 at 20:13 UTC ee0d1c5dd44bdf3b1c2795546ac90192e4ad7582
1 file changed +22 -7
src/proc_diskstats.c
+22 -7
@@ -51,6 +51,9 @@ static struct disk {
51 char *bcache_filename_cache_read_races;
52 char *bcache_filename_priority_stats;
53
54 + usec_t bcache_priority_stats_update_every_usec;
55 + usec_t bcache_priority_stats_elapsed_usec;
56 +
57 RRDSET *st_io;
58 RRDDIM *rd_io_reads;
59 RRDDIM *rd_io_writes;
@@ -138,6 +141,7 @@ static char *path_to_device_mapper = NULL;
141 static char *path_to_device_label = NULL;
142 static char *path_to_device_id = NULL;
143 static int name_disks_by_id = CONFIG_BOOLEAN_NO;
144 +static int global_bcache_priority_stats_update_every = 60;
145
146 static int global_enable_new_disks_detected_at_runtime = CONFIG_BOOLEAN_YES,
147 global_enable_performance_for_physical_disks = CONFIG_BOOLEAN_AUTO,
@@ -182,7 +186,7 @@ static unsigned long long int bcache_read_number_with_units(const char *filename
186 return 0;
187 }
188
185 -void bcache_read_priority_stats(struct disk *d, const char *family, int update_every) {
189 +void bcache_read_priority_stats(struct disk *d, const char *family, int update_every, usec_t dt) {
190 static procfile *ff = NULL;
191 static char *separators = " \t:%[]";
192
@@ -194,6 +198,12 @@ void bcache_read_priority_stats(struct disk *d, const char *family, int update_e
198 static unsigned long long metadata;
199 static unsigned long long unknown;
200
201 + // check if it is time to update this metric
202 + d->bcache_priority_stats_elapsed_usec += dt;
203 + if(likely(d->bcache_priority_stats_elapsed_usec < d->bcache_priority_stats_update_every_usec)) return;
204 + d->bcache_priority_stats_elapsed_usec = 0;
205 +
206 + // initialize ARL
207 if(unlikely(!arl_base)) {
208 arl_base = arl_create("bcache/priority_stats", NULL, 60);
209 arl_expect(arl_base, "Unused", &unused);
@@ -208,6 +218,8 @@ void bcache_read_priority_stats(struct disk *d, const char *family, int update_e
218 separators = " \t:%[]";
219 return;
220 }
221 +
222 + // do not reset the separators on every iteration
223 separators = NULL;
224
225 arl_begin(arl_base);
@@ -247,11 +259,13 @@ void bcache_read_priority_stats(struct disk *d, const char *family, int update_e
259 , RRDSET_TYPE_STACKED
260 );
261
250 - d->rd_bcache_cache_allocations_unused = rrddim_add(d->st_bcache_cache_allocations, "unused", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
251 - d->rd_bcache_cache_allocations_dirty = rrddim_add(d->st_bcache_cache_allocations, "dirty", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
252 - d->rd_bcache_cache_allocations_clean = rrddim_add(d->st_bcache_cache_allocations, "clean", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
253 - d->rd_bcache_cache_allocations_metadata = rrddim_add(d->st_bcache_cache_allocations, "metadata", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
262 + d->rd_bcache_cache_allocations_unused = rrddim_add(d->st_bcache_cache_allocations, "unused", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
263 + d->rd_bcache_cache_allocations_dirty = rrddim_add(d->st_bcache_cache_allocations, "dirty", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
264 + d->rd_bcache_cache_allocations_clean = rrddim_add(d->st_bcache_cache_allocations, "clean", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
265 + d->rd_bcache_cache_allocations_metadata = rrddim_add(d->st_bcache_cache_allocations, "metadata", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
266 d->rd_bcache_cache_allocations_unknown = rrddim_add(d->st_bcache_cache_allocations, "undefined", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
267 +
268 + d->bcache_priority_stats_update_every_usec = update_every * USEC_PER_SEC;
269 }
270 else rrdset_next(d->st_bcache_cache_allocations);
271
@@ -734,6 +748,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
748 global_do_util = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "utilization percentage for all disks", global_do_util);
749 global_do_backlog = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "backlog for all disks", global_do_backlog);
750 global_do_bcache = config_get_boolean_ondemand(CONFIG_SECTION_DISKSTATS, "bcache for all disks", global_do_bcache);
751 + global_bcache_priority_stats_update_every = (int)config_get_number(CONFIG_SECTION_DISKSTATS, "bcache priority stats update every", global_bcache_priority_stats_update_every);
752
753 global_cleanup_removed_disks = config_get_boolean(CONFIG_SECTION_DISKSTATS, "remove charts of removed disks" , global_cleanup_removed_disks);
754
@@ -1270,8 +1285,8 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1285 if(d->bcache_filename_cache_read_races)
1286 cache_read_races = bcache_read_number_with_units(d->bcache_filename_cache_read_races);
1287
1273 - if(d->bcache_filename_priority_stats)
1274 - bcache_read_priority_stats(d, family, update_every);
1288 + if(d->bcache_filename_priority_stats && global_bcache_priority_stats_update_every >= 1)
1289 + bcache_read_priority_stats(d, family, global_bcache_priority_stats_update_every, dt);
1290
1291 // update the charts
1292