collectctl: compare pointer with NULL not 0
[collectd.git] / src / disk.c
index 05a863f..bafc82e 100644 (file)
@@ -293,6 +293,7 @@ static void disk_submit (const char *plugin_instance,
        plugin_dispatch_values (&vl);
 } /* void disk_submit */
 
+#if KERNEL_FREEBSD || KERNEL_LINUX
 static void submit_io_time (char const *plugin_instance, derive_t io_time, derive_t weighted_time)
 {
        value_t values[2];
@@ -313,6 +314,7 @@ static void submit_io_time (char const *plugin_instance, derive_t io_time, deriv
 
        plugin_dispatch_values (&vl);
 } /* void submit_io_time */
+#endif /* KERNEL_FREEBSD || KERNEL_LINUX */
 
 #if KERNEL_LINUX
 static void submit_in_progress (char const *disk_name, gauge_t in_progress)
@@ -536,7 +538,7 @@ static int disk_read (void)
        struct gident *geom_id;
 
        const char *disk_name;
-       long double read_time, write_time;
+       long double read_time, write_time, busy_time, total_duration;
 
        for (retry = 0, dirty = 1; retry < 5 && dirty == 1; retry++) {
                if (snap != NULL)
@@ -631,6 +633,16 @@ static int disk_read (void)
                        disk_submit (disk_name, "disk_time",
                                        (derive_t)(read_time*1000), (derive_t)(write_time*1000));
                }
+               if (devstat_compute_statistics(snap_iter, NULL, 1.0,
+                   DSM_TOTAL_BUSY_TIME, &busy_time,
+                   DSM_TOTAL_DURATION, &total_duration,
+                   DSM_NONE) != 0) {
+                       WARNING("%s", devstat_errbuf);
+               }
+               else
+               {
+                       submit_io_time(disk_name, busy_time, total_duration);
+               }
        }
        geom_stats_snapshot_free(snap);