]> arthur.barton.de Git - netdata.git/commitdiff
use monotonic clock for apps statistics computation
authorRémi Lefèvre <remi.lefevre@parrot.com>
Tue, 13 Dec 2016 17:48:18 +0000 (18:48 +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 e3a363e34e222d5701854c8538b129702a094447..fb3082d69109ad66a3b1af58c48849d487dbc2c7 100644 (file)
@@ -610,7 +610,7 @@ static inline int read_proc_pid_stat(struct pid_stat *p) {
     if(unlikely(!ff)) goto cleanup;
 
     p->last_stat_collected_usec = p->stat_collected_usec;
-    p->stat_collected_usec = now_realtime_usec();
+    p->stat_collected_usec = now_monotonic_usec();
     file_counter++;
 
     // p->pid           = str2ul(procfile_lineword(ff, 0, 0+i));
@@ -792,7 +792,7 @@ static inline int read_proc_pid_io(struct pid_stat *p) {
     file_counter++;
 
     p->last_io_collected_usec = p->io_collected_usec;
-    p->io_collected_usec = now_realtime_usec();
+    p->io_collected_usec = now_monotonic_usec();
 
     unsigned long long last;
 
@@ -867,7 +867,7 @@ static inline int read_proc_stat() {
     if(unlikely(!ff)) goto cleanup;
 
     last_collected_usec = collected_usec;
-    collected_usec = now_realtime_usec();
+    collected_usec = now_monotonic_usec();
 
     file_counter++;
 
@@ -2209,7 +2209,7 @@ static usec_t send_resource_usage_to_netdata() {
     usec_t cpusyst;
 
     if(!last.tv_sec) {
-        now_realtime_timeval(&last);
+        now_monotonic_timeval(&last);
         getrusage(RUSAGE_SELF, &me_last);
 
         // the first time, give a zero to allow
@@ -2220,7 +2220,7 @@ static usec_t send_resource_usage_to_netdata() {
         cpusyst = 0;
     }
     else {
-        now_realtime_timeval(&now);
+        now_monotonic_timeval(&now);
         getrusage(RUSAGE_SELF, &me);
 
         usec = dt_usec(&now, &last);
@@ -2860,7 +2860,7 @@ int main(int argc, char **argv)
 
     procfile_adaptive_initial_allocation = 1;
 
-    time_t started_t = now_realtime_sec();
+    time_t started_t = now_monotonic_sec();
     get_system_HZ();
     get_system_pid_max();
     get_system_cpus();
@@ -2951,9 +2951,7 @@ int main(int argc, char **argv)
         if(unlikely(debug))
             fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter);
 
-        time_t current_t = now_realtime_sec();
-
         // restart check (14400 seconds)
-        if(current_t - started_t > 14400) exit(0);
+        if(now_monotonic_sec() - started_t > 14400) exit(0);
     }
 }