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));
+ // p->pid = str2pid_t(procfile_lineword(ff, 0, 0+i));
- strncpyz(p->comm, procfile_lineword(ff, 0, 1), MAX_COMPARE_NAME);
+ if(unlikely(!p->comm[0]))
+ strncpyz(p->comm, procfile_lineword(ff, 0, 1), MAX_COMPARE_NAME);
// p->state = *(procfile_lineword(ff, 0, 2));
- p->ppid = (int32_t)str2ul(procfile_lineword(ff, 0, 3));
+ p->ppid = (int32_t)str2pid_t(procfile_lineword(ff, 0, 3));
// p->pgrp = str2ul(procfile_lineword(ff, 0, 4));
// p->session = str2ul(procfile_lineword(ff, 0, 5));
// p->tty_nr = str2ul(procfile_lineword(ff, 0, 6));
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;
+ kernel_uint_t last;
last = p->io_logical_bytes_read_raw;
p->io_logical_bytes_read_raw = str2ull(procfile_lineword(ff, 0, 1));
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()) {
+ if(!collect_data_for_all_processes()) {
error("Cannot collect /proc data for running processes. Disabling apps.plugin...");
printf("DISABLE\n");
exit(1);
show_guest_time_old = show_guest_time;
if(unlikely(debug))
- fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter);
+ fprintf(stderr, "apps.plugin: done Loop No %zu\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);
}
}