bcache: added cache I/O errors
Costa Tsaousis (ktsaou) committed
May 29, 2018 at 20:46 UTC
14b58363b48cab33c127b8ef4e586320e91d0009
2 files changed
+19
-4
conf.d/health.d/bcache.conf
+3
-3
@@ -1,13 +1,13 @@
1
2
-template: bcache_cache_read_races
2
+template: bcache_cache_errors
3
on: disk.bcache_cache_read_races
4
lookup: sum -10m unaligned absolute
5
- units: races
5
+ units: errors
6
every: 1m
7
warn: $this > 0
8
crit: $this > ( ($status >= $CRITICAL) ? (0) : (10) )
9
delay: down 1h multiplier 1.5 max 2h
10
- info: the number of times bcache failed to read from the cache during the last 10 mins (this usually means your SSD cache is failing)
10
+ info: the number of times bcache had issues using the cache, during the last 10 mins (this usually means your SSD cache is failing)
11
to: sysadmin
12
13
template: bcache_cache_dirty
src/proc_diskstats.c
+16
-1
@@ -49,6 +49,7 @@ static struct disk {
49
char *bcache_filename_stats_total_cache_bypass_misses;
50
char *bcache_filename_stats_total_cache_readaheads;
51
char *bcache_filename_cache_read_races;
52
+ char *bcache_filename_cache_io_errors;
53
char *bcache_filename_priority_stats;
54
55
usec_t bcache_priority_stats_update_every_usec;
@@ -125,6 +126,7 @@ static struct disk {
126
127
RRDSET *st_bcache_cache_read_races;
128
RRDDIM *rd_bcache_cache_read_races;
129
+ RRDDIM *rd_bcache_cache_io_errors;
130
131
struct disk *next;
132
} *disk_root = NULL;
@@ -652,6 +654,12 @@ static struct disk *get_disk(unsigned long major, unsigned long minor, char *dis
654
else
655
error("bcache file '%s' cannot be read.", buffer2);
656
657
+ snprintfz(buffer2, FILENAME_MAX, "%s/cache/cache0/io_errors", buffer);
658
+ if(access(buffer2, R_OK) == 0)
659
+ d->bcache_filename_cache_io_errors = strdupz(buffer2);
660
+ else
661
+ error("bcache file '%s' cannot be read.", buffer2);
662
+
663
snprintfz(buffer2, FILENAME_MAX, "%s/dirty_data", buffer);
664
if(access(buffer2, R_OK) == 0)
665
d->bcache_filename_dirty_data = strdupz(buffer2);
@@ -1234,6 +1242,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1242
cache_available_percent = 0,
1243
cache_readaheads = 0,
1244
cache_read_races = 0,
1245
+ cache_io_errors = 0,
1246
cache_congested = 0,
1247
dirty_data = 0,
1248
writeback_rate = 0;
@@ -1285,6 +1294,9 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1294
if(d->bcache_filename_cache_read_races)
1295
cache_read_races = bcache_read_number_with_units(d->bcache_filename_cache_read_races);
1296
1297
+ if(d->bcache_filename_cache_io_errors)
1298
+ cache_io_errors = bcache_read_number_with_units(d->bcache_filename_cache_io_errors);
1299
+
1300
if(d->bcache_filename_priority_stats && global_bcache_priority_stats_update_every >= 1)
1301
bcache_read_priority_stats(d, family, global_bcache_priority_stats_update_every, dt);
1302
@@ -1417,11 +1429,13 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1429
, RRDSET_TYPE_LINE
1430
);
1431
1420
- d->rd_bcache_cache_read_races = rrddim_add(d->st_bcache_cache_read_races, "races", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1432
+ d->rd_bcache_cache_read_races = rrddim_add(d->st_bcache_cache_read_races, "races", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1433
+ d->rd_bcache_cache_io_errors = rrddim_add(d->st_bcache_cache_read_races, "errors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1434
}
1435
else rrdset_next(d->st_bcache_cache_read_races);
1436
1437
rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_read_races, cache_read_races);
1438
+ rrddim_set_by_pointer(d->st_bcache_cache_read_races, d->rd_bcache_cache_io_errors, cache_io_errors);
1439
rrdset_done(d->st_bcache_cache_read_races);
1440
}
1441
@@ -1574,6 +1588,7 @@ int do_proc_diskstats(int update_every, usec_t dt) {
1588
freez(t->bcache_filename_stats_total_cache_bypass_misses);
1589
freez(t->bcache_filename_stats_total_cache_readaheads);
1590
freez(t->bcache_filename_cache_read_races);
1591
+ freez(t->bcache_filename_cache_io_errors);
1592
freez(t->bcache_filename_priority_stats);
1593
1594
freez(t->disk);