Add stats for ipv4/ipv6/mixed media calls

Also Send stats for ipv4/ipv6/mixed media calls to graphite
pull/1219/head
Stefan Mititelu 4 years ago
parent f791bf03f9
commit 482e2d0d2b

@ -2115,6 +2115,19 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams,
ml_media = other_ml_media = NULL;
// reset offer ipv4/ipv6/mixed media stats
if (flags && flags->opmode == OP_OFFER) {
statistics_update_ip46_inc_dec(call, CMC_DECREMENT);
call->is_ipv4_media_offer = 0;
call->is_ipv6_media_offer = 0;
// reset answer ipv4/ipv6/mixed media stats
} else if (flags && flags->opmode == OP_ANSWER) {
statistics_update_ip46_inc_dec(call, CMC_DECREMENT);
call->is_ipv4_media_answer = 0;
call->is_ipv6_media_answer = 0;
}
for (media_iter = streams->head; media_iter; media_iter = media_iter->next) {
sp = media_iter->data;
__C_DBG("processing media stream #%u", sp->index);
@ -2237,6 +2250,20 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams,
}
if (media->desired_family->af == AF_INET) {
if (flags && flags->opmode == OP_OFFER) {
media->call->is_ipv4_media_offer = 1;
} else if (flags && flags->opmode == OP_ANSWER) {
media->call->is_ipv4_media_answer = 1;
}
} else if (media->desired_family->af == AF_INET6) {
if (flags && flags->opmode == OP_OFFER) {
media->call->is_ipv6_media_offer = 1;
} else if (flags && flags->opmode == OP_ANSWER) {
media->call->is_ipv6_media_answer = 1;
}
}
/* determine number of consecutive ports needed locally.
* XXX only do *=2 for RTP streams? */
num_ports = sp->consecutive_ports;
@ -2314,6 +2341,11 @@ init:
t38_gateway_start(media->t38_gateway);
}
// set ipv4/ipv6/mixed media stats
if (flags && (flags->opmode == OP_OFFER || flags->opmode == OP_ANSWER)) {
statistics_update_ip46_inc_dec(call, CMC_INCREMENT);
}
return 0;
error_ports:
@ -2471,6 +2503,7 @@ void call_destroy(struct call *c) {
obj_put(c);
statistics_update_ip46_inc_dec(c, CMC_DECREMENT);
statistics_update_foreignown_dec(c);
if (IS_OWN_CALL(c)) {

@ -429,6 +429,9 @@ static void cli_incoming_list_numsessions(str *instr, struct cli_writer *cw) {
cw->cw_printf(cw, "Current sessions total: %i\n", g_hash_table_size(rtpe_callhash));
rwlock_unlock_r(&rtpe_callhash_lock);
cw->cw_printf(cw, "Current transcoded media: "UINT64F"\n", atomic64_get(&rtpe_stats.transcoded_media));
cw->cw_printf(cw, "Current sessions ipv4 only media: %li\n", atomic64_get(&rtpe_stats.ipv4_sessions));
cw->cw_printf(cw, "Current sessions ipv6 only media: %li\n", atomic64_get(&rtpe_stats.ipv6_sessions));
cw->cw_printf(cw, "Current sessions ip mixed media: %li\n", atomic64_get(&rtpe_stats.mixed_sessions));
}
static void cli_incoming_list_maxsessions(str *instr, struct cli_writer *cw) {

@ -195,6 +195,9 @@ static int send_graphite_data(struct totalstats *sent_data) {
GPF("current_sessions_own "UINT64F, ts->own_sessions);
GPF("current_sessions_foreign "UINT64F, ts->foreign_sessions);
GPF("current_transcoded_media "UINT64F, atomic64_get(&rtpe_stats.transcoded_media));
GPF("current_sessions_ipv4 "UINT64F, atomic64_get(&rtpe_stats.ipv4_sessions));
GPF("current_sessions_ipv6 "UINT64F, atomic64_get(&rtpe_stats.ipv6_sessions));
GPF("current_sessions_mixed "UINT64F, atomic64_get(&rtpe_stats.mixed_sessions));
GPF("nopacket_relayed_sess "UINT64F, atomic64_get_na(&ts->total_nopacket_relayed_sess));
GPF("oneway_stream_sess "UINT64F, atomic64_get_na(&ts->total_oneway_stream_sess));
GPF("regular_term_sess "UINT64F, atomic64_get_na(&ts->total_regular_term_sess));

@ -97,6 +97,84 @@ void statistics_update_totals(struct packet_stream *ps) {
atomic64_get(&ps->stats.bytes));
}
// op can be CMC_INCREMENT or CMC_DECREMENT
// check not to multiple decrement or increment
void statistics_update_ip46_inc_dec(struct call* c, int op) {
// already incremented
if (op == CMC_INCREMENT && c->is_call_media_counted) {
return ;
// already decremented
} else if (op == CMC_DECREMENT && !c->is_call_media_counted) {
return ;
}
// offer is ipv4 only
if (c->is_ipv4_media_offer && !c->is_ipv6_media_offer) {
// answer is ipv4 only
if (c->is_ipv4_media_answer && !c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv4_sessions) : atomic64_dec(&rtpe_stats.ipv4_sessions);
// answer is ipv6 only
} else if (!c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.mixed_sessions) : atomic64_dec(&rtpe_stats.mixed_sessions);
// answer is both ipv4 and ipv6
} else if (c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv4_sessions) : atomic64_dec(&rtpe_stats.ipv4_sessions);
// answer is neither ipv4 nor ipv6
} else {
return ;
}
// offer is ipv6 only
} else if (!c->is_ipv4_media_offer && c->is_ipv6_media_offer) {
// answer is ipv4 only
if (c->is_ipv4_media_answer && !c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.mixed_sessions) : atomic64_dec(&rtpe_stats.mixed_sessions);
// answer is ipv6 only
} else if (!c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv6_sessions) : atomic64_dec(&rtpe_stats.ipv6_sessions);
// answer is both ipv4 and ipv6
} else if (c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv6_sessions) : atomic64_dec(&rtpe_stats.ipv6_sessions);
// answer is neither ipv4 nor ipv6
} else {
return ;
}
// offer is both ipv4 and ipv6
} else if (c->is_ipv4_media_offer && c->is_ipv6_media_offer) {
// answer is ipv4 only
if (c->is_ipv4_media_answer && !c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv4_sessions) : atomic64_dec(&rtpe_stats.ipv4_sessions);
// answer is ipv6 only
} else if (!c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.ipv6_sessions) : atomic64_dec(&rtpe_stats.ipv6_sessions);
// answer is both ipv4 and ipv6
} else if (c->is_ipv4_media_answer && c->is_ipv6_media_answer) {
(op == CMC_INCREMENT) ? atomic64_inc(&rtpe_stats.mixed_sessions) : atomic64_dec(&rtpe_stats.mixed_sessions);
// answer is neither ipv4 nor ipv6
} else {
return ;
}
// offer is neither ipv4 nor ipv6
} else {
return ;
}
// mark if incremented or decremented
c->is_call_media_counted = (op == CMC_INCREMENT) ? 1 : 0;
}
void statistics_update_foreignown_dec(struct call* c) {
if (IS_FOREIGN_CALL(c)) {
atomic64_dec(&rtpe_stats.foreign_sessions);

@ -52,6 +52,11 @@ enum call_opmode {
OP_OTHER,
};
enum call_media_counted {
CMC_INCREMENT = 0,
CMC_DECREMENT,
};
enum call_stream_state {
CSS_UNKNOWN = 0,
CSS_SHUTDOWN,
@ -417,6 +422,13 @@ struct call {
struct recording *recording;
str metadata;
// ipv4/ipv6 media flags
unsigned int is_ipv4_media_offer:1;
unsigned int is_ipv6_media_offer:1;
unsigned int is_ipv4_media_answer:1;
unsigned int is_ipv6_media_answer:1;
unsigned int is_call_media_counted:1;
unsigned int block_dtmf:1;
unsigned int block_media:1;
unsigned int recording_on:1;

@ -20,6 +20,9 @@ struct stats {
atomic64 answers;
atomic64 deletes;
atomic64 transcoded_media;
atomic64 ipv4_sessions;
atomic64 ipv6_sessions;
atomic64 mixed_sessions;
};
@ -125,6 +128,7 @@ extern mutex_t rtpe_codec_stats_lock;
extern GHashTable *rtpe_codec_stats;
void statistics_update_oneway(struct call *);
void statistics_update_ip46_inc_dec(struct call *, int op);
void statistics_update_foreignown_dec(struct call *);
void statistics_update_foreignown_inc(struct call* c);
void statistics_update_totals(struct packet_stream *) ;

Loading…
Cancel
Save