proc/mdstat: add raid level to the family (#11024)
Ilya Mashchenko committed
Apr 26, 2021 at 13:48 UTC
055d32dc1faa27d03aa91b6b1e25ad0da622c92a
2 files changed
+13
-7
collectors/proc.plugin/proc_mdstat.c
+12
-7
@@ -8,6 +8,7 @@ struct raid {
8
int redundant;
9
char *name;
10
uint32_t hash;
11
+ char *level;
12
13
RRDDIM *rd_health;
14
unsigned long long failed_disks;
@@ -149,6 +150,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
150
for (raid_idx = 0; raid_idx < raids_allocated; raid_idx++) {
151
struct raid *raid = &raids[raid_idx];
152
freez(raid->name);
153
+ freez(raid->level);
154
freez(raid->mismatch_cnt_filename);
155
}
156
if (raids_num) {
@@ -168,7 +170,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
170
171
words = procfile_linewords(ff, l);
172
171
- if (unlikely(words < 2))
173
+ if (unlikely(words < 3))
174
continue;
175
176
if (unlikely(procfile_lineword(ff, l, 1)[0] != 'a'))
@@ -177,12 +179,15 @@ int do_proc_mdstat(int update_every, usec_t dt)
179
if (unlikely(!raid->name)) {
180
raid->name = strdupz(procfile_lineword(ff, l, 0));
181
raid->hash = simple_hash(raid->name);
182
+ raid->level = strdupz(procfile_lineword(ff, l, 2));
183
} else if (unlikely(strcmp(raid->name, procfile_lineword(ff, l, 0)))) {
184
freez(raid->name);
185
freez(raid->mismatch_cnt_filename);
186
+ freez(raid->level);
187
memset(raid, 0, sizeof(struct raid));
188
raid->name = strdupz(procfile_lineword(ff, l, 0));
189
raid->hash = simple_hash(raid->name);
190
+ raid->level = strdupz(procfile_lineword(ff, l, 2));
191
}
192
193
if (unlikely(!raid->name || !raid->name[0]))
@@ -436,7 +441,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
441
snprintfz(id, 50, "%s_disks", raid->name);
442
443
if (unlikely(!raid->st_disks && !(raid->st_disks = rrdset_find_active_byname_localhost(id)))) {
439
- snprintfz(family, 50, "%s", raid->name);
444
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
445
446
raid->st_disks = rrdset_create_localhost(
447
"mdstat",
@@ -473,7 +478,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
478
snprintfz(id, 50, "%s_mismatch", raid->name);
479
480
if (unlikely(!raid->st_mismatch_cnt && !(raid->st_mismatch_cnt = rrdset_find_active_byname_localhost(id)))) {
476
- snprintfz(family, 50, "%s", raid->name);
481
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
482
483
raid->st_mismatch_cnt = rrdset_create_localhost(
484
"mdstat",
@@ -507,7 +512,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
512
snprintfz(id, 50, "%s_operation", raid->name);
513
514
if (unlikely(!raid->st_operation && !(raid->st_operation = rrdset_find_active_byname_localhost(id)))) {
510
- snprintfz(family, 50, "%s", raid->name);
515
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
516
517
raid->st_operation = rrdset_create_localhost(
518
"mdstat",
@@ -548,7 +553,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
553
snprintfz(id, 50, "%s_finish", raid->name);
554
555
if (unlikely(!raid->st_finish && !(raid->st_finish = rrdset_find_active_byname_localhost(id)))) {
551
- snprintfz(family, 50, "%s", raid->name);
556
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
557
558
raid->st_finish = rrdset_create_localhost(
559
"mdstat",
@@ -579,7 +584,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
584
snprintfz(id, 50, "%s_speed", raid->name);
585
586
if (unlikely(!raid->st_speed && !(raid->st_speed = rrdset_find_active_byname_localhost(id)))) {
582
- snprintfz(family, 50, "%s", raid->name);
587
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
588
589
raid->st_speed = rrdset_create_localhost(
590
"mdstat",
@@ -613,7 +618,7 @@ int do_proc_mdstat(int update_every, usec_t dt)
618
snprintfz(id, 50, "%s_availability", raid->name);
619
620
if (unlikely(!raid->st_nonredundant && !(raid->st_nonredundant = rrdset_find_active_localhost(id)))) {
616
- snprintfz(family, 50, "%s", raid->name);
621
+ snprintfz(family, 50, "%s (%s)", raid->name, raid->level);
622
623
raid->st_nonredundant = rrdset_create_localhost(
624
"mdstat",
health/health.d/mdstat.conf
+1
@@ -29,6 +29,7 @@ component: RAID
29
class: System
30
component: RAID
31
type: Errors
32
+ families: !*(raid1) !*(raid10) *
33
units: unsynchronized blocks
34
calc: $count
35
every: 60s