]> arthur.barton.de Git - netdata.git/blobdiff - src/plugin_proc_diskspace.c
Merge pull request #1744 from l2isbad/web_log_plugin
[netdata.git] / src / plugin_proc_diskspace.c
index 9a395541a5df92795c04e5de956eef0dc654bfea..689efe7c7a0d93a3fbbe4b9cf9494bff0d848dd8 100644 (file)
@@ -96,7 +96,7 @@ static inline void do_disk_space_stats(struct mountinfo *mi, int update_every) {
                 .rd_inodes_reserved = NULL
         };
 
-        dictionary_set(mount_points, mi->mount_point, &mp, sizeof(struct mount_point_metadata));
+        m = dictionary_set(mount_points, mi->mount_point, &mp, sizeof(struct mount_point_metadata));
     }
     else {
         do_space = m->do_space;
@@ -231,20 +231,13 @@ void *proc_diskspace_main(void *ptr) {
 
     struct rusage thread;
 
-    usec_t last = 0, dt = 0;
+    usec_t duration = 0;
     usec_t step = update_every * USEC_PER_SEC;
+    heartbeat_t hb;
+    heartbeat_init(&hb);
     for(;;) {
-        usec_t now = now_monotonic_usec();
-        usec_t next = now - (now % step) + step;
-
-        dt = (last)?now - last:0;
-
-        while(now < next) {
-            sleep_usec(next - now);
-            now = now_monotonic_usec();
-        }
-
-        last = now;
+        duration = heartbeat_dt_usec(&hb);
+        /* usec_t hb_dt = */ heartbeat_next(&hb, step);
 
         if(unlikely(netdata_exit)) break;
 
@@ -307,7 +300,7 @@ void *proc_diskspace_main(void *ptr) {
             else
                 rrdset_next(st_duration);
 
-            rrddim_set_by_pointer(st_duration, rd_duration, dt);
+            rrddim_set_by_pointer(st_duration, rd_duration, duration);
             rrdset_done(st_duration);
 
             // ----------------------------------------------------------------