]> arthur.barton.de Git - netdata.git/commitdiff
convert apps_plugin to heartbeat API
authorRémi Lefèvre <remi.lefevre@parrot.com>
Tue, 13 Dec 2016 17:18:05 +0000 (18:18 +0100)
committerRémi Lefèvre <remi.lefevre@parrot.com>
Mon, 23 Jan 2017 16:39:46 +0000 (17:39 +0100)
Signed-off-by: Rémi Lefèvre <remi.lefevre@parrot.com>
src/apps_plugin.c

index 0a72190aaff7ccbc3cf1e794a997bd7c6416f7e4..e3a363e34e222d5701854c8538b129702a094447 100644 (file)
@@ -2903,9 +2903,9 @@ int main(int argc, char **argv)
 
     usec_t step = update_every * USEC_PER_SEC;
     global_iterations_counter = 1;
+    heartbeat_t hb;
+    heartbeat_init(&hb);
     for(;1; global_iterations_counter++) {
-        usec_t now = now_realtime_usec();
-        usec_t next = now - (now % step) + step;
 
 #ifdef NETDATA_PROFILING
 #warning "compiling for profiling"
@@ -2913,10 +2913,7 @@ int main(int argc, char **argv)
         profiling_count++;
         if(unlikely(profiling_count > 1000)) exit(0);
 #else
-        while(now < next) {
-            sleep_usec(next - now);
-            now = now_realtime_usec();
-        }
+        heartbeat_next(&hb, step);
 #endif
 
         if(!collect_data_for_all_processes_from_proc()) {