From 551d51be96b0110afde8e17b848daca7eb7d09b2 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sat, 6 Sep 2014 11:47:37 +0200 Subject: [PATCH] disk plugin: Add metric for pending I/O operations. This is only supported on Linux right now. Fixes: #705 --- src/disk.c | 24 ++++++++++++++++++++++++ src/types.db | 1 + 2 files changed, 25 insertions(+) diff --git a/src/disk.c b/src/disk.c index cdf2816d..e84e8355 100644 --- a/src/disk.c +++ b/src/disk.c @@ -272,6 +272,26 @@ static void disk_submit (const char *plugin_instance, } /* void disk_submit */ #if KERNEL_LINUX +static void submit_in_progress (char const *disk_name, gauge_t in_progress) +{ + value_t v; + value_list_t vl = VALUE_LIST_INIT; + + if (ignorelist_match (ignorelist, disk_name) != 0) + return; + + v.gauge = in_progress; + + vl.values = &v; + vl.values_len = 1; + sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + sstrncpy (vl.plugin, "disk", sizeof (vl.plugin)); + sstrncpy (vl.plugin_instance, disk_name, sizeof (vl.plugin_instance)); + sstrncpy (vl.type, "pending_operations", sizeof (vl.type)); + + plugin_dispatch_values (&vl); +} + static counter_t disk_calc_time_incr (counter_t delta_time, counter_t delta_ops) { double interval = CDTIME_T_TO_DOUBLE (plugin_get_interval ()); @@ -539,6 +559,7 @@ static int disk_read (void) derive_t write_ops = 0; derive_t write_merged = 0; derive_t write_time = 0; + gauge_t in_progress = NAN; int is_disk = 0; diskstats_t *ds, *pre_ds; @@ -620,6 +641,8 @@ static int disk_read (void) read_time = atoll (fields[6 + fieldshift]); write_merged = atoll (fields[8 + fieldshift]); write_time = atoll (fields[10+ fieldshift]); + + in_progress = atof (fields[11 + fieldshift]); } } else @@ -743,6 +766,7 @@ static int disk_read (void) { disk_submit (output_name, "disk_merged", read_merged, write_merged); + submit_in_progress (output_name, in_progress); } /* if (is_disk) */ /* release udev-based alternate name, if allocated */ diff --git a/src/types.db b/src/types.db index fcdea23b..64137b07 100644 --- a/src/types.db +++ b/src/types.db @@ -122,6 +122,7 @@ node_stat value:DERIVE:0:U node_tx_rate value:GAUGE:0:127 objects value:GAUGE:0:U operations value:DERIVE:0:U +pending_operations value:GAUGE:0:U percent value:GAUGE:0:100.1 percent_bytes value:GAUGE:0:100.1 percent_inodes value:GAUGE:0:100.1 -- 2.30.2