Code

Added support for the last two additional columns in add-linux-io-time
authorMichael Schenck <mschenck@digitalocean.com>
Tue, 7 Oct 2014 02:40:24 +0000 (22:40 -0400)
committerMichael Schenck <mschenck@digitalocean.com>
Tue, 7 Oct 2014 02:40:24 +0000 (22:40 -0400)
src/disk.c
src/types.db

index e84e8355af2f802d3ce6a610ab76c45c264ad82b..9c8d1e593878fab256f433d9172b38b3de8e5329 100644 (file)
@@ -292,6 +292,28 @@ static void submit_in_progress (char const *disk_name, gauge_t in_progress)
        plugin_dispatch_values (&vl);
 }
 
+static void submit_io_time (char const *plugin_instance, derive_t io_time, derive_t weighted_time)
+{
+       value_t values[2];
+       value_list_t vl = VALUE_LIST_INIT;
+
+       if (ignorelist_match (ignorelist, plugin_instance) != 0)
+         return;
+
+       values[0].derive = io_time;
+       values[1].derive = weighted_time;
+
+       vl.values = values;
+       vl.values_len = 2;
+       sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+       sstrncpy (vl.plugin, "disk", sizeof (vl.plugin));
+       sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));
+       sstrncpy (vl.type, "disk_io_time", 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 ());
@@ -560,6 +582,8 @@ static int disk_read (void)
        derive_t write_merged  = 0;
        derive_t write_time    = 0;
        gauge_t in_progress    = NAN;
+       derive_t io_time       = 0;
+       derive_t weighted_time = 0;
        int is_disk = 0;
 
        diskstats_t *ds, *pre_ds;
@@ -643,6 +667,9 @@ static int disk_read (void)
                                write_time   = atoll (fields[10+ fieldshift]);
 
                                in_progress = atof (fields[11 + fieldshift]);
+
+                               io_time       = atof (fields[12 + fieldshift]);
+                               weighted_time = atof (fields[13 + fieldshift]);
                        }
                }
                else
@@ -767,6 +794,7 @@ static int disk_read (void)
                        disk_submit (output_name, "disk_merged",
                                        read_merged, write_merged);
                        submit_in_progress (output_name, in_progress);
+                       submit_io_time (io_time, weighted_time);
                } /* if (is_disk) */
 
                /* release udev-based alternate name, if allocated */
index 64137b07a8bcad3b2e2c3882bad8a4a5beb5bf92..fc75153fb79cba7ff376432908f57c6d59bbca97 100644 (file)
@@ -37,6 +37,7 @@ disk_octets           read:DERIVE:0:U, write:DERIVE:0:U
 disk_ops_complex       value:DERIVE:0:U
 disk_ops               read:DERIVE:0:U, write:DERIVE:0:U
 disk_time              read:DERIVE:0:U, write:DERIVE:0:U
+disk_io_time           io_time:DERIVE:0:U, weighted_io_time:DERIVE:0:U
 dns_answer             value:DERIVE:0:U
 dns_notify             value:DERIVE:0:U
 dns_octets             queries:DERIVE:0:U, responses:DERIVE:0:U