diff --git a/daemon/call.c b/daemon/call.c index 03ad9c61d..f34e30072 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -42,6 +42,7 @@ #include "statistics.h" #include "ssrc.h" #include "main.h" +#include "graphite.h" /* also serves as array index for callstream->peers[] */ @@ -1720,7 +1721,7 @@ out: void add_total_calls_duration_in_interval(struct callmaster *cm, struct timeval *interval_tv) { struct timeval ongoing_calls_dur = add_ongoing_calls_dur_in_interval(cm, - &cm->latest_graphite_interval_start, interval_tv); + &rtpe_latest_graphite_interval_start, interval_tv); mutex_lock(&rtpe_totalstats_interval.total_calls_duration_lock); timeval_add(&rtpe_totalstats_interval.total_calls_duration_interval, diff --git a/daemon/call.h b/daemon/call.h index 274fd70ac..ca77b17f8 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -417,7 +417,6 @@ struct callmaster { struct obj obj; struct callmaster_config conf; - struct timeval latest_graphite_interval_start; }; diff --git a/daemon/graphite.c b/daemon/graphite.c index 227dbf877..3699c6a0e 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -22,6 +22,8 @@ #include "socket.h" #include "statistics.h" +struct timeval rtpe_latest_graphite_interval_start; + static socket_t graphite_sock; static int connection_state = STATE_DISCONNECTED; //struct totalstats totalstats_prev; @@ -311,7 +313,7 @@ void graphite_loop_run(struct callmaster *cm, endpoint_t *graphite_ep, int secon add_total_calls_duration_in_interval(cm, &graphite_interval_tv); rc = send_graphite_data(cm, &graphite_stats); - gettimeofday(&cm->latest_graphite_interval_start, NULL); + gettimeofday(&rtpe_latest_graphite_interval_start, NULL); if (rc < 0) { ilog(LOG_ERROR,"Sending graphite data failed."); close_socket(&graphite_sock); diff --git a/daemon/graphite.h b/daemon/graphite.h index 9ffd34c70..d83ccbc2d 100644 --- a/daemon/graphite.h +++ b/daemon/graphite.h @@ -16,6 +16,8 @@ enum connection_state { STATE_CONNECTED, }; +extern struct timeval rtpe_latest_graphite_interval_start; + int connect_to_graphite_server(const endpoint_t *ep); int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data); void graphite_loop_run(struct callmaster *cm, endpoint_t *graphite_ep, int seconds); diff --git a/daemon/main.c b/daemon/main.c index 345e81beb..9689a9dd9 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -37,6 +37,7 @@ #include "rtcp.h" #include "iptables.h" #include "statistics.h" +#include "graphite.h" @@ -638,7 +639,7 @@ no_kernel: ilog(LOG_INFO, "Redis restore time = %.0lf ms", redis_diff); } - gettimeofday(&ctx->m->latest_graphite_interval_start, NULL); + gettimeofday(&rtpe_latest_graphite_interval_start, NULL); timeval_from_us(&tmp_tv, (long long) graphite_interval*1000000); set_graphite_interval_tv(&tmp_tv); diff --git a/daemon/statistics.c b/daemon/statistics.c index 1c39a797f..de788b554 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -1,5 +1,6 @@ #include "call.h" #include "statistics.h" +#include "graphite.h" struct totalstats rtpe_totalstats; struct totalstats rtpe_totalstats_interval; @@ -203,7 +204,7 @@ void statistics_update_oneway(struct call* c) { timeval_totalstats_average_add(&rtpe_totalstats_interval, &tim_result_duration); timeval_totalstats_interval_call_duration_add( &rtpe_totalstats_interval, &ml->started, &ml->terminated, - &m->latest_graphite_interval_start, + &rtpe_latest_graphite_interval_start, m->conf.graphite_interval); }