make apps.plugin report timings from heartbeat() - on Azure monotonic and realtime have 10 second delta every 5 minutes
Costa Tsaousis (ktsaou) committed
Apr 21, 2017 at 21:49 UTC
933f2370bbffbc645e259f77df4fe3f7082def94
1 file changed
+9
-15
src/apps_plugin.c
+9
-15
@@ -2599,14 +2599,13 @@ static inline void send_END(void) {
2599
fprintf(stdout, "END\n");
2600
}
2601
2602
-static usec_t send_resource_usage_to_netdata() {
2602
+void send_resource_usage_to_netdata(usec_t dt) {
2603
static struct timeval last = { 0, 0 };
2604
static struct rusage me_last;
2605
2606
struct timeval now;
2607
struct rusage me;
2608
2609
- usec_t usec;
2609
usec_t cpuuser;
2610
usec_t cpusyst;
2611
@@ -2614,10 +2613,6 @@ static usec_t send_resource_usage_to_netdata() {
2613
now_monotonic_timeval(&last);
2614
getrusage(RUSAGE_SELF, &me_last);
2615
2617
- // the first time, give a zero to allow
2618
- // netdata calibrate to the current time
2619
- // usec = update_every * USEC_PER_SEC;
2620
- usec = 0ULL;
2616
cpuuser = 0;
2617
cpusyst = 0;
2618
}
@@ -2625,7 +2620,6 @@ static usec_t send_resource_usage_to_netdata() {
2620
now_monotonic_timeval(&now);
2621
getrusage(RUSAGE_SELF, &me);
2622
2628
- usec = dt_usec(&now, &last);
2623
cpuuser = me.ru_utime.tv_sec * USEC_PER_SEC + me.ru_utime.tv_usec;
2624
cpusyst = me.ru_stime.tv_sec * USEC_PER_SEC + me.ru_stime.tv_usec;
2625
@@ -2684,10 +2678,10 @@ static usec_t send_resource_usage_to_netdata() {
2678
"SET targets = %zu\n"
2679
"SET new_pids = %zu\n"
2680
"END\n"
2687
- , usec
2681
+ , dt
2682
, cpuuser
2683
, cpusyst
2690
- , usec
2684
+ , dt
2685
, calls_counter
2686
, file_counter
2687
, all_pids_count
@@ -2705,7 +2699,7 @@ static usec_t send_resource_usage_to_netdata() {
2699
"SET minflt = %u\n"
2700
"SET majflt = %u\n"
2701
"END\n"
2708
- , usec
2702
+ , dt
2703
, (unsigned int)(utime_fix_ratio * 100 * RATES_DETAIL)
2704
, (unsigned int)(stime_fix_ratio * 100 * RATES_DETAIL)
2705
, (unsigned int)(gtime_fix_ratio * 100 * RATES_DETAIL)
@@ -2722,7 +2716,7 @@ static usec_t send_resource_usage_to_netdata() {
2716
"SET cminflt = %u\n"
2717
"SET cmajflt = %u\n"
2718
"END\n"
2725
- , usec
2719
+ , dt
2720
, (unsigned int)(cutime_fix_ratio * 100 * RATES_DETAIL)
2721
, (unsigned int)(cstime_fix_ratio * 100 * RATES_DETAIL)
2722
, (unsigned int)(cgtime_fix_ratio * 100 * RATES_DETAIL)
@@ -2730,8 +2724,6 @@ static usec_t send_resource_usage_to_netdata() {
2724
, (unsigned int)(cmajflt_fix_ratio * 100 * RATES_DETAIL)
2725
);
2726
#endif
2733
-
2734
- return usec;
2727
}
2728
2729
#if (ALL_PIDS_ARE_READ_INSTANTLY == 0)
@@ -3462,8 +3454,9 @@ int main(int argc, char **argv) {
3454
static int profiling_count=0;
3455
profiling_count++;
3456
if(unlikely(profiling_count > 1000)) exit(0);
3457
+ usec_t dt = update_every * USEC_PER_SEC;
3458
#else
3466
- heartbeat_next(&hb, step);
3459
+ usec_t dt = heartbeat_next(&hb, step);
3460
#endif
3461
3462
if(!collect_data_for_all_processes()) {
@@ -3475,7 +3468,8 @@ int main(int argc, char **argv) {
3468
calculate_netdata_statistics();
3469
normalize_utilization(apps_groups_root_target);
3470
3478
- usec_t dt = send_resource_usage_to_netdata();
3471
+ send_resource_usage_to_netdata(dt);
3472
+ if(global_iterations_counter == 1) dt = 0;
3473
3474
// this is smart enough to show only newly added apps, when needed
3475
send_charts_updates_to_netdata(apps_groups_root_target, "apps", "Apps");