diff --git a/daemon/statistics.c b/daemon/statistics.c index 19f8e7600..5716f401d 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -9,7 +9,7 @@ #include "control_ng.h" #include "bufferpool.h" -struct timeval rtpe_started; +int64_t rtpe_started; mutex_t rtpe_codec_stats_lock; @@ -387,7 +387,7 @@ stats_metric_q *statistics_gather_metrics(struct interface_sampled_rate_stats *i HEADER("totalstatistics", "Total statistics (does not include current running sessions):"); HEADER("{", ""); - METRIC("uptime", "Uptime of rtpengine", "%" PRId64, "%" PRId64 " seconds", timeval_diff(timeval_from_us(rtpe_now), rtpe_started) / 1000000); + METRIC("uptime", "Uptime of rtpengine", "%" PRId64, "%" PRId64 " seconds", (rtpe_now - rtpe_started) / 1000000); PROM("uptime_seconds", "gauge"); METRIC("managedsessions", "Total managed sessions", "%" PRIu64, "%" PRIu64, num_sessions); @@ -948,7 +948,7 @@ static void codec_stats_free(struct codec_stats *stats_entry) { TYPED_GHASHTABLE_IMPL(codec_stats_ht, c_str_hash, c_str_equal, NULL, codec_stats_free) void statistics_init(void) { - gettimeofday(&rtpe_started, NULL); + rtpe_started = now_us(); rtpe_stats = bufferpool_alloc0(shm_bufferpool, sizeof(*rtpe_stats)); mutex_init(&rtpe_codec_stats_lock); diff --git a/include/statistics.h b/include/statistics.h index ceaaf5068..310ab8042 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -101,7 +101,7 @@ struct call_stats { struct stream_stats totals[4]; /* rtp in, rtcp in, rtp out, rtcp out */ }; -extern struct timeval rtpe_started; +extern int64_t rtpe_started; extern mutex_t rtpe_codec_stats_lock; extern codec_stats_ht rtpe_codec_stats; diff --git a/t/test-stats.c b/t/test-stats.c index 77458e43a..e83cea6c7 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -82,7 +82,7 @@ int main(void) { // fake current time rtpe_now = 150 * 1000000LL; - rtpe_started = (struct timeval) {80,0}; + rtpe_started = 80 * 1000000LL; // test cmd_time_min/max/avg