|
|
|
@ -28,6 +28,11 @@ static struct callmaster* cm=0;
|
|
|
|
static time_t next_run;
|
|
|
|
static time_t next_run;
|
|
|
|
// HEAD: static time_t g_now, next_run;
|
|
|
|
// HEAD: static time_t g_now, next_run;
|
|
|
|
static char* graphite_prefix = NULL;
|
|
|
|
static char* graphite_prefix = NULL;
|
|
|
|
|
|
|
|
static struct timeval graphite_interval_tv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void set_graphite_interval_tv(struct timeval *tv) {
|
|
|
|
|
|
|
|
graphite_interval_tv = *tv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void set_prefix(char* prefix) {
|
|
|
|
void set_prefix(char* prefix) {
|
|
|
|
graphite_prefix = prefix;
|
|
|
|
graphite_prefix = prefix;
|
|
|
|
@ -126,13 +131,36 @@ int send_graphite_data() {
|
|
|
|
ZERO(cm->totalstats_interval.total_managed_sess);
|
|
|
|
ZERO(cm->totalstats_interval.total_managed_sess);
|
|
|
|
mutex_unlock(&cm->totalstats_interval.total_average_lock);
|
|
|
|
mutex_unlock(&cm->totalstats_interval.total_average_lock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mutex_lock(&cm->totalstats_interval.total_calls_duration_lock);
|
|
|
|
|
|
|
|
ts.total_calls_duration_interval = cm->totalstats_interval.total_calls_duration_interval;
|
|
|
|
|
|
|
|
cm->totalstats_interval.total_calls_duration_interval.tv_sec = 0;
|
|
|
|
|
|
|
|
cm->totalstats_interval.total_calls_duration_interval.tv_usec = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ZERO(cm->totalstats_interval.total_calls_duration_interval);
|
|
|
|
|
|
|
|
mutex_unlock(&cm->totalstats_interval.total_calls_duration_lock);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rwlock_lock_r(&cm->hashlock);
|
|
|
|
|
|
|
|
mutex_lock(&cm->totalstats_interval.managed_sess_lock);
|
|
|
|
|
|
|
|
ts.managed_sess_max = cm->totalstats_interval.managed_sess_max;
|
|
|
|
|
|
|
|
ts.managed_sess_min = cm->totalstats_interval.managed_sess_min;
|
|
|
|
|
|
|
|
cm->totalstats_interval.managed_sess_max = cm->totalstats.managed_sess_crt;
|
|
|
|
|
|
|
|
cm->totalstats_interval.managed_sess_min = cm->totalstats.managed_sess_crt;
|
|
|
|
|
|
|
|
mutex_unlock(&cm->totalstats_interval.managed_sess_lock);
|
|
|
|
|
|
|
|
rwlock_unlock_r(&cm->hashlock);
|
|
|
|
|
|
|
|
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.average_call_dur %llu.%06llu %llu\n",hostname, (unsigned long long) cm->totalstats_interval.total_average_call_dur.tv_sec,(unsigned long long) cm->totalstats_interval.total_average_call_dur.tv_usec,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr, "%s.totals.call_dur %llu.%06llu %llu\n",hostname,(unsigned long long)ts.total_calls_duration_interval.tv_sec,(unsigned long long)ts.total_calls_duration_interval.tv_usec,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
|
|
|
|
rc = sprintf(ptr,"%s.totals.average_call_dur %llu.%06llu %llu\n",hostname,(unsigned long long)ts.total_average_call_dur.tv_sec,(unsigned long long)ts.total_average_call_dur.tv_usec,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.forced_term_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_forced_term_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr,"%s.totals.forced_term_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_forced_term_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.managed_sess "UINT64F" %llu\n",hostname, ts.total_managed_sess,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr,"%s.totals.managed_sess "UINT64F" %llu\n",hostname, ts.total_managed_sess,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
|
|
|
|
rc = sprintf(ptr,"%s.totals.managed_sess_min "UINT64F" %llu\n",hostname, ts.managed_sess_min,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
|
|
|
|
rc = sprintf(ptr,"%s.totals.managed_sess_max "UINT64F" %llu\n",hostname, ts.managed_sess_max,(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.nopacket_relayed_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_nopacket_relayed_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr,"%s.totals.nopacket_relayed_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_nopacket_relayed_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.oneway_stream_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_oneway_stream_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr,"%s.totals.oneway_stream_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_oneway_stream_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
@ -149,6 +177,12 @@ int send_graphite_data() {
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s.",graphite_prefix); ptr += rc; }
|
|
|
|
rc = sprintf(ptr,"%s.totals.reject_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_rejected_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
rc = sprintf(ptr,"%s.totals.reject_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_rejected_sess),(unsigned long long)g_now.tv_sec); ptr += rc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ilog(LOG_DEBUG, "min_sessions:%u max_sessions:%u, call_dur_per_interval:%llu.%06llu at time %llu\n",
|
|
|
|
|
|
|
|
ts.managed_sess_min, ts.managed_sess_max,
|
|
|
|
|
|
|
|
(unsigned long long ) ts.total_calls_duration_interval.tv_sec,
|
|
|
|
|
|
|
|
(unsigned long long ) ts.total_calls_duration_interval.tv_usec,
|
|
|
|
|
|
|
|
(unsigned long long ) g_now.tv_sec);
|
|
|
|
|
|
|
|
|
|
|
|
rc = write(graphite_sock, data_to_send, ptr - data_to_send);
|
|
|
|
rc = write(graphite_sock, data_to_send, ptr - data_to_send);
|
|
|
|
if (rc<0) {
|
|
|
|
if (rc<0) {
|
|
|
|
ilog(LOG_ERROR,"Could not write to graphite socket. Disconnecting graphite server.");
|
|
|
|
ilog(LOG_ERROR,"Could not write to graphite socket. Disconnecting graphite server.");
|
|
|
|
@ -225,7 +259,9 @@ void graphite_loop_run(struct callmaster* callmaster, int seconds) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (graphite_sock>0 && !connectinprogress) {
|
|
|
|
if (graphite_sock>0 && !connectinprogress) {
|
|
|
|
|
|
|
|
add_total_calls_duration_in_interval(cm, &graphite_interval_tv);
|
|
|
|
rc = send_graphite_data();
|
|
|
|
rc = send_graphite_data();
|
|
|
|
|
|
|
|
gettimeofday(&cm->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.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|