@cryptotaxi247 / netdata-1 / commits / d7beda03a

use monotonic clock for apps statistics computation

Signed-off-by: Rémi Lefèvre <remi.lefevre@parrot.com>

Rémi Lefèvre committed Dec 13, 2016 at 18:48 UTC d7beda03ad0b34c6eef1f5c92ebcc872d3f4f406
1 file changed +7 -9
src/apps_plugin.c
+7 -9
@@ -610,7 +610,7 @@ static inline int read_proc_pid_stat(struct pid_stat *p) {
610 if(unlikely(!ff)) goto cleanup;
611
612 p->last_stat_collected_usec = p->stat_collected_usec;
613 - p->stat_collected_usec = now_realtime_usec();
613 + p->stat_collected_usec = now_monotonic_usec();
614 file_counter++;
615
616 // p->pid = str2ul(procfile_lineword(ff, 0, 0+i));
@@ -792,7 +792,7 @@ static inline int read_proc_pid_io(struct pid_stat *p) {
792 file_counter++;
793
794 p->last_io_collected_usec = p->io_collected_usec;
795 - p->io_collected_usec = now_realtime_usec();
795 + p->io_collected_usec = now_monotonic_usec();
796
797 unsigned long long last;
798
@@ -867,7 +867,7 @@ static inline int read_proc_stat() {
867 if(unlikely(!ff)) goto cleanup;
868
869 last_collected_usec = collected_usec;
870 - collected_usec = now_realtime_usec();
870 + collected_usec = now_monotonic_usec();
871
872 file_counter++;
873
@@ -2209,7 +2209,7 @@ static usec_t send_resource_usage_to_netdata() {
2209 usec_t cpusyst;
2210
2211 if(!last.tv_sec) {
2212 - now_realtime_timeval(&last);
2212 + now_monotonic_timeval(&last);
2213 getrusage(RUSAGE_SELF, &me_last);
2214
2215 // the first time, give a zero to allow
@@ -2220,7 +2220,7 @@ static usec_t send_resource_usage_to_netdata() {
2220 cpusyst = 0;
2221 }
2222 else {
2223 - now_realtime_timeval(&now);
2223 + now_monotonic_timeval(&now);
2224 getrusage(RUSAGE_SELF, &me);
2225
2226 usec = dt_usec(&now, &last);
@@ -2860,7 +2860,7 @@ int main(int argc, char **argv)
2860
2861 procfile_adaptive_initial_allocation = 1;
2862
2863 - time_t started_t = now_realtime_sec();
2863 + time_t started_t = now_monotonic_sec();
2864 get_system_HZ();
2865 get_system_pid_max();
2866 get_system_cpus();
@@ -2951,9 +2951,7 @@ int main(int argc, char **argv)
2951 if(unlikely(debug))
2952 fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter);
2953
2954 - time_t current_t = now_realtime_sec();
2955 -
2954 // restart check (14400 seconds)
2957 - if(current_t - started_t > 14400) exit(0);
2955 + if(now_monotonic_sec() - started_t > 14400) exit(0);
2956 }
2957 }