From 369316adb037a7313281711f35b8cc1b020d059d Mon Sep 17 00:00:00 2001 From: Pawel Kuzak Date: Tue, 12 May 2015 17:32:27 +0200 Subject: [PATCH] Added rejected sessions statistics to total stats and graphite --- daemon/call.h | 1 + daemon/call_interfaces.c | 2 ++ daemon/cli.c | 2 ++ daemon/graphite.c | 3 +++ 4 files changed, 8 insertions(+) diff --git a/daemon/call.h b/daemon/call.h index 40c0ca699..309a7d1f7 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -223,6 +223,7 @@ struct stats { struct totalstats { time_t started; atomic64 total_timeout_sess; + atomic64 total_rejected_sess; atomic64 total_silent_timeout_sess; atomic64 total_regular_term_sess; atomic64 total_forced_term_sess; diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 242a82134..73ddec05c 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -697,6 +697,8 @@ const char *call_offer_ng(bencode_item_t *input, struct callmaster *m, bencode_i rwlock_lock_r(&m->hashlock); if (g_hash_table_size(m->callhash) >= m->conf.max_sessions) { rwlock_unlock_r(&m->hashlock); + atomic64_inc(&m->totalstats.total_rejected_sess); + atomic64_inc(&m->totalstats_interval.total_rejected_sess); ilog(LOG_ERROR, "Parallel session limit reached (%i)",m->conf.max_sessions); snprintf(errstr, 64, "Parallel session limit reached (%i)",m->conf.max_sessions); return errstr; diff --git a/daemon/cli.c b/daemon/cli.c index e41397c08..50ee6c7d6 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -42,6 +42,8 @@ static void cli_incoming_list_totals(char* buffer, int len, struct callmaster* m ADJUSTLEN(printlen,outbufend,replybuffer); printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total managed sessions :"UINT64F"\n", num_sessions); ADJUSTLEN(printlen,outbufend,replybuffer); + printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total rejected sessions :"UINT64F"\n", atomic64_get(&m->totalstats.total_rejected_sess)); + ADJUSTLEN(printlen,outbufend,replybuffer); printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via TIMEOUT :"UINT64F"\n",atomic64_get(&m->totalstats.total_timeout_sess)); ADJUSTLEN(printlen,outbufend,replybuffer); printlen = snprintf(replybuffer,(outbufend-replybuffer), " Total timed-out sessions via SILENT_TIMEOUT :"UINT64F"\n",atomic64_get(&m->totalstats.total_silent_timeout_sess)); diff --git a/daemon/graphite.c b/daemon/graphite.c index 14fcd1bb1..e072597de 100644 --- a/daemon/graphite.c +++ b/daemon/graphite.c @@ -135,6 +135,7 @@ int send_graphite_data() { /* atomically copy values to stack and reset to zero */ atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_timeout_sess); + atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_rejected_sess); atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_silent_timeout_sess); atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_regular_term_sess); atomic64_local_copy_zero_struct(&ts, &cm->totalstats_interval, total_forced_term_sess); @@ -172,6 +173,8 @@ int send_graphite_data() { rc = sprintf(ptr,"%s.totals.silent_timeout_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_silent_timeout_sess),(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.timeout_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_timeout_sess),(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.reject_sess "UINT64F" %llu\n",hostname, atomic64_get_na(&ts.total_rejected_sess),(unsigned long long)g_now.tv_sec); ptr += rc; rc = write(graphite_sock, data_to_send, ptr - data_to_send); if (rc<0) {