From db58aa80d0b1ca942cf290099058ae5f458da4ce Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 15 May 2018 11:17:12 -0400 Subject: [PATCH] fix graphite interval calculation for call durations closes #543 Change-Id: I60f88cd874051c44df21b0b20401d1603ba5832e --- daemon/statistics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/statistics.c b/daemon/statistics.c index 8a3745fda..b17223107 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -46,7 +46,12 @@ static void timeval_totalstats_interval_call_duration_add(struct totalstats *s, /* in case graphite interval needs to be the previous one */ if (timercmp(&real_iv_start, call_stop, >)) { - struct timeval graph_dur = { .tv_sec = interval_dur_s, .tv_usec = 0LL }; + // round up to nearest while interval_dur_s + long long d = timeval_diff(&real_iv_start, call_stop); + d += (interval_dur_s * 1000000) - 1; + d /= 1000000 * interval_dur_s; + d *= interval_dur_s; + struct timeval graph_dur = { .tv_sec = d, .tv_usec = 0LL }; timeval_subtract(&real_iv_start, interval_start, &graph_dur); }