@cryptotaxi247 / netdata-1 / commits / 8c093a84b

Hide archived chart from mdstat collector. (#9667)

* Hide archived chart from mdstat collector. * Fix dimension lookups.

Markos Fountoulakis committed Aug 5, 2020 at 17:31 UTC 8c093a84b1fdec838313af4a60fc90ff084d2e54
2 files changed +20 -12
collectors/proc.plugin/proc_mdstat.c
+12 -12
@@ -392,7 +392,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
392 struct raid *raid = &raids[raid_idx];
393
394 if(likely(raid->redundant)) {
395 - if(unlikely(!raid->rd_health && !(raid->rd_health = rrddim_find(st_mdstat_health, raid->name))))
395 + if(unlikely(!raid->rd_health && !(raid->rd_health = rrddim_find_active(st_mdstat_health, raid->name))))
396 raid->rd_health = rrddim_add(st_mdstat_health, raid->name, NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
397
398 rrddim_set_by_pointer(st_mdstat_health, raid->rd_health, raid->failed_disks);
@@ -437,9 +437,9 @@ int do_proc_mdstat(int update_every, usec_t dt) {
437 else
438 rrdset_next(raid->st_disks);
439
440 - if(unlikely(!raid->rd_inuse && !(raid->rd_inuse = rrddim_find(raid->st_disks, "inuse"))))
440 + if(unlikely(!raid->rd_inuse && !(raid->rd_inuse = rrddim_find_active(raid->st_disks, "inuse"))))
441 raid->rd_inuse = rrddim_add(raid->st_disks, "inuse", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
442 - if(unlikely(!raid->rd_down && !(raid->rd_down = rrddim_find(raid->st_disks, "down"))))
442 + if(unlikely(!raid->rd_down && !(raid->rd_down = rrddim_find_active(raid->st_disks, "down"))))
443 raid->rd_down = rrddim_add(raid->st_disks, "down", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
444
445 rrddim_set_by_pointer(raid->st_disks, raid->rd_inuse, raid->inuse_disks);
@@ -476,7 +476,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
476 else
477 rrdset_next(raid->st_mismatch_cnt);
478
479 - if(unlikely(!raid->rd_mismatch_cnt && !(raid->rd_mismatch_cnt = rrddim_find(raid->st_mismatch_cnt, "count"))))
479 + if(unlikely(!raid->rd_mismatch_cnt && !(raid->rd_mismatch_cnt = rrddim_find_active(raid->st_mismatch_cnt, "count"))))
480 raid->rd_mismatch_cnt = rrddim_add(raid->st_mismatch_cnt, "count", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
481
482 rrddim_set_by_pointer(raid->st_mismatch_cnt, raid->rd_mismatch_cnt, raid->mismatch_cnt);
@@ -512,13 +512,13 @@ int do_proc_mdstat(int update_every, usec_t dt) {
512 else
513 rrdset_next(raid->st_operation);
514
515 - if(unlikely(!raid->rd_check && !(raid->rd_check = rrddim_find(raid->st_operation, "check"))))
515 + if(unlikely(!raid->rd_check && !(raid->rd_check = rrddim_find_active(raid->st_operation, "check"))))
516 raid->rd_check = rrddim_add(raid->st_operation, "check", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE);
517 - if(unlikely(!raid->rd_resync && !(raid->rd_resync = rrddim_find(raid->st_operation, "resync"))))
517 + if(unlikely(!raid->rd_resync && !(raid->rd_resync = rrddim_find_active(raid->st_operation, "resync"))))
518 raid->rd_resync = rrddim_add(raid->st_operation, "resync", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE);
519 - if(unlikely(!raid->rd_recovery && !(raid->rd_recovery = rrddim_find(raid->st_operation, "recovery"))))
519 + if(unlikely(!raid->rd_recovery && !(raid->rd_recovery = rrddim_find_active(raid->st_operation, "recovery"))))
520 raid->rd_recovery = rrddim_add(raid->st_operation, "recovery", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE);
521 - if(unlikely(!raid->rd_reshape && !(raid->rd_reshape = rrddim_find(raid->st_operation, "reshape"))))
521 + if(unlikely(!raid->rd_reshape && !(raid->rd_reshape = rrddim_find_active(raid->st_operation, "reshape"))))
522 raid->rd_reshape = rrddim_add(raid->st_operation, "reshape", NULL, 1, 100, RRD_ALGORITHM_ABSOLUTE);
523
524 rrddim_set_by_pointer(raid->st_operation, raid->rd_check, raid->check);
@@ -555,7 +555,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
555 else
556 rrdset_next(raid->st_finish);
557
558 - if(unlikely(!raid->rd_finish_in && !(raid->rd_finish_in = rrddim_find(raid->st_finish, "finish_in"))))
558 + if(unlikely(!raid->rd_finish_in && !(raid->rd_finish_in = rrddim_find_active(raid->st_finish, "finish_in"))))
559 raid->rd_finish_in = rrddim_add(raid->st_finish, "finish_in", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
560
561 rrddim_set_by_pointer(raid->st_finish, raid->rd_finish_in, raid->finish_in);
@@ -589,7 +589,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
589 else
590 rrdset_next(raid->st_speed);
591
592 - if(unlikely(!raid->rd_speed && !(raid->rd_speed = rrddim_find(raid->st_speed, "speed"))))
592 + if(unlikely(!raid->rd_speed && !(raid->rd_speed = rrddim_find_active(raid->st_speed, "speed"))))
593 raid->rd_speed = rrddim_add(raid->st_speed, "speed", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
594
595 rrddim_set_by_pointer(raid->st_speed, raid->rd_speed, raid->speed);
@@ -604,7 +604,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
604 if(likely(do_nonredundant)) {
605 snprintfz(id, 50, "%s_availability", raid->name);
606
607 - if(unlikely(!raid->st_nonredundant && !(raid->st_nonredundant = rrdset_find_localhost(id)))) {
607 + if(unlikely(!raid->st_nonredundant && !(raid->st_nonredundant = rrdset_find_active_localhost(id)))) {
608 snprintfz(family, 50, "%s", raid->name);
609
610 raid->st_nonredundant = rrdset_create_localhost(
@@ -627,7 +627,7 @@ int do_proc_mdstat(int update_every, usec_t dt) {
627 else
628 rrdset_next(raid->st_nonredundant);
629
630 - if(unlikely(!raid->rd_nonredundant && !(raid->rd_nonredundant = rrddim_find(raid->st_nonredundant, "available"))))
630 + if(unlikely(!raid->rd_nonredundant && !(raid->rd_nonredundant = rrddim_find_active(raid->st_nonredundant, "available"))))
631 raid->rd_nonredundant = rrddim_add(raid->st_nonredundant, "available", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
632
633 rrddim_set_by_pointer(raid->st_nonredundant, raid->rd_nonredundant, 1);
database/rrd.h
+8
@@ -965,6 +965,14 @@ extern void rrdset_update_heterogeneous_flag(RRDSET *st);
965
966 extern RRDSET *rrdset_find(RRDHOST *host, const char *id);
967 #define rrdset_find_localhost(id) rrdset_find(localhost, id)
968 +/* This will not return charts that are archived */
969 +static inline RRDSET *rrdset_find_active_localhost(const char *id)
970 +{
971 + RRDSET *st = rrdset_find_localhost(id);
972 + if (unlikely(st && rrdset_flag_check(st, RRDSET_FLAG_ARCHIVED)))
973 + return NULL;
974 + return st;
975 +}
976
977 extern RRDSET *rrdset_find_bytype(RRDHOST *host, const char *type, const char *id);
978 #define rrdset_find_bytype_localhost(type, id) rrdset_find_bytype(localhost, type, id)