diff --git a/daemon/call.c b/daemon/call.c index f700cfea4..536890693 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -572,9 +572,6 @@ void call_timer(void *ptr) { stats_counters_calc_rate(&rtpe_stats, run_diff_us, &rtpe_stats_intv, &rtpe_stats_rate); - // TODO: should be moved into a separate thread/timer - stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); - // stats derived while iterating calls RTPE_GAUGE_SET(transcoded_media, hlp.transcoded_media); diff --git a/daemon/main.c b/daemon/main.c index f16d069db..3b3cfec52 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1350,6 +1350,10 @@ int main(int argc, char **argv) { thread_create_detach_prio(sockets_releaser, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority, "release closed sockets"); + /* separate thread for update of running min/max call counters */ + thread_create_detach_prio(call_rate_stats_updater, NULL, rtpe_config.idle_scheduling, + rtpe_config.idle_priority, "call rate stats"); + if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async) thread_create_detach(redis_delete_async_loop, NULL, "redis async"); diff --git a/daemon/statistics.c b/daemon/statistics.c index bee446b4e..c881b42b6 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -1017,3 +1017,16 @@ const char *statistics_ng(bencode_item_t *input, bencode_item_t *output) { return NULL; } + +/** + * Separate thread for update of running min/max call counters. + */ +void call_rate_stats_updater(void * dummy) { + while (!rtpe_shutdown) { + stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); + + thread_cancel_enable(); + usleep(1000000); /* sleep for 1 second in each iteration */ + thread_cancel_disable(); + } +} diff --git a/include/statistics.h b/include/statistics.h index fc5f85c92..38485b318 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -197,6 +197,7 @@ void statistics_update_foreignown_inc(struct call* c); GQueue *statistics_gather_metrics(struct interface_sampled_rate_stats *); void statistics_free_metrics(GQueue **); const char *statistics_ng(bencode_item_t *input, bencode_item_t *output); +void call_rate_stats_updater(void * dummy); INLINE void stats_counters_calc_rate(const struct global_stats_counter *stats, long long run_diff_us, struct global_stats_counter *intv, struct global_stats_counter *rate)