|
|
|
|
@ -37,6 +37,23 @@ void set_prefix(char* prefix) {
|
|
|
|
|
graphite_prefix = prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct request_time timeval_clear_request_time(struct request_time *request) {
|
|
|
|
|
struct request_time ret;
|
|
|
|
|
|
|
|
|
|
mutex_lock(&request->lock);
|
|
|
|
|
ret = *request;
|
|
|
|
|
request->time_min.tv_sec = 0;
|
|
|
|
|
request->time_min.tv_usec = 0;
|
|
|
|
|
request->time_max.tv_sec = 0;
|
|
|
|
|
request->time_max.tv_usec = 0;
|
|
|
|
|
request->time_avg.tv_sec = 0;
|
|
|
|
|
request->time_avg.tv_usec = 0;
|
|
|
|
|
request->count = 0;
|
|
|
|
|
mutex_unlock(&request->lock);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int connect_to_graphite_server(const endpoint_t *graphite_ep) {
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
@ -105,10 +122,13 @@ int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data) {
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
ts->offer = timeval_clear_request_time(&cm->totalstats_interval.offer);
|
|
|
|
|
ts->answer = timeval_clear_request_time(&cm->totalstats_interval.answer);
|
|
|
|
|
ts->delete = timeval_clear_request_time(&cm->totalstats_interval.delete);
|
|
|
|
|
|
|
|
|
|
rwlock_lock_r(&cm->hashlock);
|
|
|
|
|
mutex_lock(&cm->totalstats_interval.managed_sess_lock);
|
|
|
|
|
ts->managed_sess_max = cm->totalstats_interval.managed_sess_max;
|
|
|
|
|
@ -118,6 +138,32 @@ int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data) {
|
|
|
|
|
mutex_unlock(&cm->totalstats_interval.managed_sess_lock);
|
|
|
|
|
rwlock_unlock_r(&cm->hashlock);
|
|
|
|
|
|
|
|
|
|
// compute average offer/answer/delete time
|
|
|
|
|
timeval_divide(&ts->offer.time_avg, &ts->offer.time_avg, ts->offer.count);
|
|
|
|
|
timeval_divide(&ts->answer.time_avg, &ts->answer.time_avg, ts->answer.count);
|
|
|
|
|
timeval_divide(&ts->delete.time_avg, &ts->delete.time_avg, ts->delete.count);
|
|
|
|
|
|
|
|
|
|
if (graphite_prefix!=NULL) { rc = sprintf(ptr,"%s",graphite_prefix); ptr += rc; }
|
|
|
|
|
rc = sprintf(ptr,"offer_time_min %llu.%06llu %llu\n",(unsigned long long)ts->offer.time_min.tv_sec,(unsigned long long)ts->offer.time_min.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,"offer_time_max %llu.%06llu %llu\n",(unsigned long long)ts->offer.time_max.tv_sec,(unsigned long long)ts->offer.time_max.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,"offer_time_avg %llu.%06llu %llu\n",(unsigned long long)ts->offer.time_avg.tv_sec,(unsigned long long)ts->offer.time_avg.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,"answer_time_min %llu.%06llu %llu\n",(unsigned long long)ts->answer.time_min.tv_sec,(unsigned long long)ts->answer.time_min.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,"answer_time_max %llu.%06llu %llu\n",(unsigned long long)ts->answer.time_max.tv_sec,(unsigned long long)ts->answer.time_max.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,"answer_time_avg %llu.%06llu %llu\n",(unsigned long long)ts->answer.time_avg.tv_sec,(unsigned long long)ts->answer.time_avg.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,"delete_time_min %llu.%06llu %llu\n",(unsigned long long)ts->delete.time_min.tv_sec,(unsigned long long)ts->delete.time_min.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,"delete_time_max %llu.%06llu %llu\n",(unsigned long long)ts->delete.time_max.tv_sec,(unsigned long long)ts->delete.time_max.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,"delete_time_avg %llu.%06llu %llu\n",(unsigned long long)ts->delete.time_avg.tv_sec,(unsigned long long)ts->delete.time_avg.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, "call_dur %llu.%06llu %llu\n",(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; }
|
|
|
|
|
@ -154,6 +200,19 @@ int send_graphite_data(struct callmaster *cm, struct totalstats *sent_data) {
|
|
|
|
|
(unsigned long long ) ts->total_calls_duration_interval.tv_usec,
|
|
|
|
|
(unsigned long long ) g_now.tv_sec);
|
|
|
|
|
|
|
|
|
|
ilog(LOG_DEBUG, "Min/Max/Avg offer processing delay: %llu.%06llu/%llu.%06llu/%llu.%06llu sec",
|
|
|
|
|
(unsigned long long)ts->offer.time_min.tv_sec,(unsigned long long)ts->offer.time_min.tv_usec,
|
|
|
|
|
(unsigned long long)ts->offer.time_max.tv_sec,(unsigned long long)ts->offer.time_max.tv_usec,
|
|
|
|
|
(unsigned long long)ts->offer.time_avg.tv_sec,(unsigned long long)ts->offer.time_avg.tv_usec);
|
|
|
|
|
ilog(LOG_DEBUG, "Min/Max/Avg answer processing delay: %llu.%06llu/%llu.%06llu/%llu.%06llu sec",
|
|
|
|
|
(unsigned long long)ts->answer.time_min.tv_sec,(unsigned long long)ts->answer.time_min.tv_usec,
|
|
|
|
|
(unsigned long long)ts->answer.time_max.tv_sec,(unsigned long long)ts->answer.time_max.tv_usec,
|
|
|
|
|
(unsigned long long)ts->answer.time_avg.tv_sec,(unsigned long long)ts->answer.time_avg.tv_usec);
|
|
|
|
|
ilog(LOG_DEBUG, "Min/Max/Avg delete processing delay: %llu.%06llu/%llu.%06llu/%llu.%06llu sec",
|
|
|
|
|
(unsigned long long)ts->delete.time_min.tv_sec,(unsigned long long)ts->delete.time_min.tv_usec,
|
|
|
|
|
(unsigned long long)ts->delete.time_max.tv_sec,(unsigned long long)ts->delete.time_max.tv_usec,
|
|
|
|
|
(unsigned long long)ts->delete.time_avg.tv_sec,(unsigned long long)ts->delete.time_avg.tv_usec);
|
|
|
|
|
|
|
|
|
|
rc = write(graphite_sock.fd, data_to_send, ptr - data_to_send);
|
|
|
|
|
if (rc<0) {
|
|
|
|
|
ilog(LOG_ERROR,"Could not write to graphite socket. Disconnecting graphite server.");
|
|
|
|
|
|