Browse Source

move latest_graphite_interval_start to global scope

Change-Id: I1eb5ea8d6faafe40383d3bb92517307e47ceca9a
pull/432/merge
Richard Fuchs 8 years ago
parent
commit
d65a6bbbdc
6 changed files with 11 additions and 5 deletions
  1. +2
    -1
      daemon/call.c
  2. +0
    -1
      daemon/call.h
  3. +3
    -1
      daemon/graphite.c
  4. +2
    -0
      daemon/graphite.h
  5. +2
    -1
      daemon/main.c
  6. +2
    -1
      daemon/statistics.c

+ 2
- 1
daemon/call.c View File

@ -42,6 +42,7 @@
#include "statistics.h" #include "statistics.h"
#include "ssrc.h" #include "ssrc.h"
#include "main.h" #include "main.h"
#include "graphite.h"
/* also serves as array index for callstream->peers[] */ /* also serves as array index for callstream->peers[] */
@ -1720,7 +1721,7 @@ out:
void add_total_calls_duration_in_interval(struct callmaster *cm, void add_total_calls_duration_in_interval(struct callmaster *cm,
struct timeval *interval_tv) { struct timeval *interval_tv) {
struct timeval ongoing_calls_dur = add_ongoing_calls_dur_in_interval(cm, 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); mutex_lock(&rtpe_totalstats_interval.total_calls_duration_lock);
timeval_add(&rtpe_totalstats_interval.total_calls_duration_interval, timeval_add(&rtpe_totalstats_interval.total_calls_duration_interval,


+ 0
- 1
daemon/call.h View File

@ -417,7 +417,6 @@ struct callmaster {
struct obj obj; struct obj obj;
struct callmaster_config conf; struct callmaster_config conf;
struct timeval latest_graphite_interval_start;
}; };


+ 3
- 1
daemon/graphite.c View File

@ -22,6 +22,8 @@
#include "socket.h" #include "socket.h"
#include "statistics.h" #include "statistics.h"
struct timeval rtpe_latest_graphite_interval_start;
static socket_t graphite_sock; static socket_t graphite_sock;
static int connection_state = STATE_DISCONNECTED; static int connection_state = STATE_DISCONNECTED;
//struct totalstats totalstats_prev; //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); add_total_calls_duration_in_interval(cm, &graphite_interval_tv);
rc = send_graphite_data(cm, &graphite_stats); rc = send_graphite_data(cm, &graphite_stats);
gettimeofday(&cm->latest_graphite_interval_start, NULL);
gettimeofday(&rtpe_latest_graphite_interval_start, NULL);
if (rc < 0) { if (rc < 0) {
ilog(LOG_ERROR,"Sending graphite data failed."); ilog(LOG_ERROR,"Sending graphite data failed.");
close_socket(&graphite_sock); close_socket(&graphite_sock);


+ 2
- 0
daemon/graphite.h View File

@ -16,6 +16,8 @@ enum connection_state {
STATE_CONNECTED, STATE_CONNECTED,
}; };
extern struct timeval rtpe_latest_graphite_interval_start;
int connect_to_graphite_server(const endpoint_t *ep); int connect_to_graphite_server(const endpoint_t *ep);
int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data); int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data);
void graphite_loop_run(struct callmaster *cm, endpoint_t *graphite_ep, int seconds); void graphite_loop_run(struct callmaster *cm, endpoint_t *graphite_ep, int seconds);


+ 2
- 1
daemon/main.c View File

@ -37,6 +37,7 @@
#include "rtcp.h" #include "rtcp.h"
#include "iptables.h" #include "iptables.h"
#include "statistics.h" #include "statistics.h"
#include "graphite.h"
@ -638,7 +639,7 @@ no_kernel:
ilog(LOG_INFO, "Redis restore time = %.0lf ms", redis_diff); 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); timeval_from_us(&tmp_tv, (long long) graphite_interval*1000000);
set_graphite_interval_tv(&tmp_tv); set_graphite_interval_tv(&tmp_tv);


+ 2
- 1
daemon/statistics.c View File

@ -1,5 +1,6 @@
#include "call.h" #include "call.h"
#include "statistics.h" #include "statistics.h"
#include "graphite.h"
struct totalstats rtpe_totalstats; struct totalstats rtpe_totalstats;
struct totalstats rtpe_totalstats_interval; 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_average_add(&rtpe_totalstats_interval, &tim_result_duration);
timeval_totalstats_interval_call_duration_add( timeval_totalstats_interval_call_duration_add(
&rtpe_totalstats_interval, &ml->started, &ml->terminated, &rtpe_totalstats_interval, &ml->started, &ml->terminated,
&m->latest_graphite_interval_start,
&rtpe_latest_graphite_interval_start,
m->conf.graphite_interval); m->conf.graphite_interval);
} }


Loading…
Cancel
Save