|
|
|
@ -1022,27 +1022,17 @@ const char *statistics_ng(bencode_item_t *input, bencode_item_t *output) { |
|
|
|
/** |
|
|
|
* Separate thread for update of running min/max call counters. |
|
|
|
*/ |
|
|
|
void call_rate_stats_updater(void * dummy) { |
|
|
|
bool first_run = true; |
|
|
|
struct timeval last_run = (struct timeval) {0,0}; |
|
|
|
enum thread_looper_action call_rate_stats_updater() { |
|
|
|
static struct timeval last_run; |
|
|
|
|
|
|
|
while (!rtpe_shutdown) { |
|
|
|
struct timeval tv_start; |
|
|
|
long long run_diff_us; |
|
|
|
stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); |
|
|
|
|
|
|
|
gettimeofday(&tv_start, NULL); /* current run */ |
|
|
|
run_diff_us = timeval_diff(&tv_start, &last_run); /* TODO: do we need `run_diff_us` at all? */ |
|
|
|
last_run = tv_start; /* for the next cycle */ |
|
|
|
|
|
|
|
stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); |
|
|
|
|
|
|
|
if (!first_run) /* `stats_counters_calc_rate()` shouldn't be called on the very first cycle */ |
|
|
|
stats_counters_calc_rate(&rtpe_stats, run_diff_us, &rtpe_stats_intv, &rtpe_stats_rate); |
|
|
|
if (!last_run.tv_sec) { /* `stats_counters_calc_rate()` shouldn't be called on the very first cycle */ |
|
|
|
long long run_diff_us = timeval_diff(&rtpe_now, &last_run); |
|
|
|
stats_counters_calc_rate(&rtpe_stats, run_diff_us, &rtpe_stats_intv, &rtpe_stats_rate); |
|
|
|
} |
|
|
|
|
|
|
|
thread_cancel_enable(); |
|
|
|
usleep(1000000); /* sleep for 1 second in each iteration */ |
|
|
|
thread_cancel_disable(); |
|
|
|
last_run = rtpe_now; |
|
|
|
|
|
|
|
first_run = false; |
|
|
|
} |
|
|
|
return TLA_CONTINUE; |
|
|
|
} |