about summary refs log tree commit diff
path: root/diskstats.c
diff options
context:
space:
mode:
authorHeikki Kallasjoki <fis@zem.fi>2018-11-30 17:05:38 +0000
committerHeikki Kallasjoki <fis@zem.fi>2018-11-30 17:05:38 +0000
commit7aa7f859f29d87d5b2628ad7f1dca27f36ceae13 (patch)
treeb7dc85e1f3aed8cef1f7aad4a7d810a53941b36b /diskstats.c
parent5a33aec2b710e4d21377e5b82f4b0bdf6a13a408 (diff)
downloadnano-exporter-7aa7f859f29d87d5b2628ad7f1dca27f36ceae13.tar.gz
nano-exporter-7aa7f859f29d87d5b2628ad7f1dca27f36ceae13.tar.xz
nano-exporter-7aa7f859f29d87d5b2628ad7f1dca27f36ceae13.zip
Add the discard metrics to diskstats collector.
Diffstat (limited to 'diskstats.c')
-rw-r--r--diskstats.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/diskstats.c b/diskstats.c
index da5ec6c..2514e3d 100644
--- a/diskstats.c
+++ b/diskstats.c
@@ -10,6 +10,9 @@
 // size of input buffer for paths and lines
 #define BUF_SIZE 256
 
+// assumed constant size of disk sector in /proc/diskstats
+#define SECTOR_SIZE 512
+
 static void *diskstats_init(int argc, char *argv[]);
 static void diskstats_collect(scrape_req *req, void *ctx);
 
@@ -51,20 +54,19 @@ static const struct {
 } columns[] = {
   { .metric = "node_disk_reads_completed_total", .factor = 1.0 },
   { .metric = "node_disk_reads_merged_total", .factor = 1.0 },
-  { .metric = "node_disk_read_bytes_total", .factor = 512.0 },  // TODO: always 512-byte sectors?
+  { .metric = "node_disk_read_bytes_total", .factor = SECTOR_SIZE },
   { .metric = "node_disk_read_time_seconds_total", .factor = 0.001 },
   { .metric = "node_disk_writes_completed_total", .factor = 1.0 },
   { .metric = "node_disk_writes_merged_total", .factor = 1.0 },
-  { .metric = "node_disk_written_bytes_total", .factor = 512.0 },  // TODO: constant?
-  { .metric = "node_disk_write_time_seconds_total", .factor = 0.001 },  // TODO: constant?
+  { .metric = "node_disk_written_bytes_total", .factor = SECTOR_SIZE },
+  { .metric = "node_disk_write_time_seconds_total", .factor = 0.001 },
   { .metric = "node_disk_io_now", .factor = 1.0 },
   { .metric = "node_disk_io_time_seconds_total", .factor = 0.001 },
   { .metric = "node_disk_io_time_weighted_seconds_total", .factor = 0.001 },
-  // TODO: metrics for 4.18+ discard fields
-  // - # of discards completed
-  // - # of discards merged
-  // - # of sectors discarded
-  // - # of milliseconds spent discarding
+  { .metric = "node_disk_discards_completed_total", .factor = 1.0 },
+  { .metric = "node_disk_discards_merged_total", .factor = 1.0 },
+  { .metric = "node_disk_discarded_sectors_total", .factor = 1.0 },
+  { .metric = "node_disk_discard_time_seconds_total", .factor = 0.001 },
 };
 #define NCOLUMNS (sizeof columns / sizeof *columns)