convert plugin_proc_diskspace to heartbeat API
Signed-off-by: Rémi Lefèvre <remi.lefevre@parrot.com>
Rémi Lefèvre committed
Jan 23, 2017 at 17:16 UTC
71d4ee67b0bc3da3acf3ecd06b0739b4f4087504
1 file changed
+6
-13
src/plugin_proc_diskspace.c
+6
-13
@@ -231,20 +231,13 @@ void *proc_diskspace_main(void *ptr) {
231
232
struct rusage thread;
233
234
- usec_t last = 0, dt = 0;
234
+ usec_t duration = 0;
235
usec_t step = update_every * USEC_PER_SEC;
236
+ heartbeat_t hb;
237
+ heartbeat_init(&hb);
238
for(;;) {
237
- usec_t now = now_monotonic_usec();
238
- usec_t next = now - (now % step) + step;
239
-
240
- dt = (last)?now - last:0;
241
-
242
- while(now < next) {
243
- sleep_usec(next - now);
244
- now = now_monotonic_usec();
245
- }
246
-
247
- last = now;
239
+ duration = heartbeat_dt_usec(&hb);
240
+ usec_t hb_dt = heartbeat_next(&hb, step);
241
242
if(unlikely(netdata_exit)) break;
243
@@ -307,7 +300,7 @@ void *proc_diskspace_main(void *ptr) {
300
else
301
rrdset_next(st_duration);
302
310
- rrddim_set_by_pointer(st_duration, rd_duration, dt);
303
+ rrddim_set_by_pointer(st_duration, rd_duration, duration);
304
rrdset_done(st_duration);
305
306
// ----------------------------------------------------------------