void get_peer_xml_buffer(char* prntBuf, MgPeerSta* cfm);
void megaco_cli_print_usage(switch_stream_handle_t *stream);
switch_status_t handle_show_activecalls_cli_cmd(switch_stream_handle_t *stream, megaco_profile_t* mg_profile);
+switch_status_t handle_show_stats(switch_stream_handle_t *stream, megaco_profile_t* mg_profile);
/******************************************************************************/
/* mg <mg-profile> show activecalls */
megaco_profile_release(profile);
handle_show_activecalls_cli_cmd(stream, profile);
+ /*******************************************************************/
+ } else if(!strcasecmp(argv[3], "stats")){
+ /*******************************************************************/
+ /* mg <mg-profile> show stats */
+ megaco_profile_release(profile);
+ handle_show_stats(stream, profile);
/*******************************************************************/
}else if(!strcasecmp(argv[3], "alltermstatus")){
/*******************************************************************/
stream->write_function(stream, "Usage: Profile Specific\n");
stream->write_function(stream, "mg profile <profile-name> start \n");
stream->write_function(stream, "mg profile <profile-name> stop \n");
- stream->write_function(stream, "mg profile <profile-name> status \n");
- stream->write_function(stream, "mg profile <profile-name> xmlstatus \n");
+ //stream->write_function(stream, "mg profile <profile-name> status \n");
+ //stream->write_function(stream, "mg profile <profile-name> xmlstatus \n");
stream->write_function(stream, "mg profile <profile-name> peerxmlstatus \n");
- stream->write_function(stream, "mg profile <profile-name> send sc <term-id> <method> <reason> \n");
- stream->write_function(stream, "mg profile <profile-name> send notify <term-id> <digits> \n");
- stream->write_function(stream, "mg profile <profile-name> send ito notify \n");
- stream->write_function(stream, "mg profile <profile-name> send cng <term-id> \n");
+ //stream->write_function(stream, "mg profile <profile-name> send sc <term-id> <method> <reason> \n");
+ //stream->write_function(stream, "mg profile <profile-name> send notify <term-id> <digits> \n");
+ //stream->write_function(stream, "mg profile <profile-name> send ito notify \n");
+ //stream->write_function(stream, "mg profile <profile-name> send cng <term-id> \n");
stream->write_function(stream, "mg profile <profile-name> show activecalls \n");
stream->write_function(stream, "mg profile <profile-name> show termstatus <term-id> \n");
stream->write_function(stream, "mg profile <profile-name> show alltermstatus \n");
return SWITCH_STATUS_SUCCESS;
}
+/******************************************************************************/
+switch_status_t handle_show_stats(switch_stream_handle_t *stream, megaco_profile_t* mg_profile)
+{
+ if(!mg_profile || !mg_profile->mg_stats){
+ stream->write_function(stream, "-ERR NULL profile/term pointer \n");
+ return SWITCH_STATUS_FALSE;
+ }
+
+ stream->write_function(stream, "Total Number of Physical ADD received = %d \n", mg_profile->mg_stats->total_num_of_phy_add_recvd);
+ stream->write_function(stream, "Total Number of RTP ADD received = %d \n", mg_profile->mg_stats->total_num_of_rtp_add_recvd);
+ stream->write_function(stream, "Total Number of SUB received = %d \n", mg_profile->mg_stats->total_num_of_sub_recvd);
+ stream->write_function(stream, "Total Number of CALL received = %d \n", mg_profile->mg_stats->total_num_of_call_recvd);
+ stream->write_function(stream, "Total Number of ADD failed = %d \n", mg_profile->mg_stats->total_num_of_add_failed);
+ stream->write_function(stream, "Total Number of Term Already in context Error = %d \n",
+ mg_profile->mg_stats->total_num_of_term_already_in_ctxt_error);
+ stream->write_function(stream, "Total Number of choose context failed Error = %d \n",
+ mg_profile->mg_stats->total_num_of_choose_ctxt_failed_error);
+ stream->write_function(stream, "Total Number of choose term failed Error = %d \n",
+ mg_profile->mg_stats->total_num_of_choose_term_failed_error);
+ stream->write_function(stream, "Total Number of find term failed Error = %d \n",
+ mg_profile->mg_stats->total_num_of_find_term_failed_error);
+ stream->write_function(stream, "Total Number of get context failed Error = %d \n",
+ mg_profile->mg_stats->total_num_of_get_ctxt_failed_error);
+ stream->write_function(stream, "Total Number of un-supported codec error = %d \n",
+ mg_profile->mg_stats->total_num_of_un_supported_codec_error);
+ stream->write_function(stream, "Total Number of Term addition to context failed error = %d \n",
+ mg_profile->mg_stats->total_num_of_add_term_failed_error);
+ stream->write_function(stream, "Total Number of Term activation failed error = %d \n",
+ mg_profile->mg_stats->total_num_of_term_activation_failed_error);
+ stream->write_function(stream, "Total Number of Term not found in context error = %d \n",
+ mg_profile->mg_stats->total_num_of_no_term_ctxt_error);
+
+
+
+ return SWITCH_STATUS_SUCCESS;
+}
+/******************************************************************************/
+
mg_ctxt = megaco_choose_context(mg_profile);
if(NULL == mg_ctxt){
+ mg_profile->mg_stats->total_num_of_choose_ctxt_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," megaco_choose_context failed \n");
- mg_util_set_err_string(&errTxt, " Resource Failure ");
- err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
- goto error;
+ mg_util_set_err_string(&errTxt, " Resource Failure ");
+ err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
+ goto error;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
" megaco_get_context failed for context-id[%ld]\n", inc_cmd->contextId.val.val);
#endif
+ mg_profile->mg_stats->total_num_of_get_ctxt_failed_error++;
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
goto error;
(MGT_TERMID_CHOOSE == termId->type.val)){
term = megaco_choose_termination(mg_profile, mg_profile->rtp_termination_id_prefix);
+ mg_profile->mg_stats->total_num_of_rtp_add_recvd++;
if(NULL == term){
+ mg_profile->mg_stats->total_num_of_choose_term_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," megaco_choose_termination failed \n");
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
/********************************************************************/
}else{ /* Physical termination */
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
+ mg_profile->mg_stats->total_num_of_phy_add_recvd++;
if(NULL == term){
+ mg_profile->mg_stats->total_num_of_find_term_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
" megaco_find_termination failed for term-id[%s] \n",(char*)termId->name.lcl.val);
mg_util_set_err_string(&errTxt, " Resource Failure ");
/* check if termination already is in call */
if(term->context){
+ mg_profile->mg_stats->total_num_of_term_already_in_ctxt_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," Termination[%p : %s] "
"already in context[%p -%d]..rejecting ADD \n",
(void*)term, term->name, (void*)term->context,term->context->context_id);
/* IF there is any error , return */
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
+ mg_profile->mg_stats->total_num_of_un_supported_codec_error++;
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
goto error;
/* associate physical termination to context */
if(SWITCH_STATUS_FALSE == megaco_context_add_termination(mg_ctxt, term)){
+ mg_profile->mg_stats->total_num_of_add_term_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"megaco_context_add_termination failed \n");
mg_util_set_err_string(&errTxt, " Resource Failure ");
err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR;
/* only for RTP */
if(SWITCH_STATUS_FALSE == mg_build_sdp(&desc->u.media, inc_med_desc, mg_profile, term, &rsp.u.mgCmdRsp[0]->memCp)) {
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
+ mg_profile->mg_stats->total_num_of_un_supported_codec_error++;
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
err_code = MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT;
goto error;
return ret;
error:
+ mg_profile->mg_stats->total_num_of_add_failed++;
if (SWITCH_STATUS_SUCCESS ==
mg_build_mgco_err_request(&mgErr, txn_id, ctxtId, err_code, &errTxt)) {
sng_mgco_send_err(mg_profile->idx, mgErr);
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
if(NULL == term){
+ mg_profile->mg_stats->total_num_of_find_term_failed_error++;
mg_util_set_term_string(&errTxt,termId);
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
goto error;
/*find context based on received context-id */
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
if(NULL == mg_ctxt){
+ mg_profile->mg_stats->total_num_of_get_ctxt_failed_error++;
#ifdef BIT_64
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Modify request Failed, context[%d] not found \n",ctxtId->val.val);
}
if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
+ mg_profile->mg_stats->total_num_of_no_term_ctxt_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Modify request Failed, requested term not associated with any context \n");
/* ERROR - termination didnt bind with requested context */
/* IF there is any error , return */
if(term->mg_error_code && (*term->mg_error_code == MGT_MGCP_RSP_CODE_INCONSISTENT_LCL_OPT)){
+ mg_profile->mg_stats->total_num_of_un_supported_codec_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Modify request Failed, Unsupported Codec \n");
mg_util_set_err_string(&errTxt, " Unsupported Codec ");
/* SDP updated to termination */
if(SWITCH_STATUS_SUCCESS != megaco_activate_termination(term)) {
+ mg_profile->mg_stats->total_num_of_term_activation_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Modify request Failed, Activation of termination failed \n");
mg_util_set_err_string(&errTxt, " Resource Failure ");
termLst = mg_get_term_id_list(inc_cmd);
termId = termLst->terms[0];
+ mg_profile->mg_stats->total_num_of_sub_recvd++;
+
/************************************************************************************************************************************************************/
/* Validating Subtract request *******************************************/
/*find context based on received context-id */
mg_ctxt = megaco_get_context(mg_profile, ctxtId->val.val);
if(NULL == mg_ctxt){
+ mg_profile->mg_stats->total_num_of_get_ctxt_failed_error++;
mg_util_set_ctxt_string(&errTxt, ctxtId);
err_code = MGT_MGCO_RSP_CODE_UNKNOWN_CTXT;
goto error;
term = megaco_find_termination(mg_profile, (char*)termId->name.lcl.val);
- if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
+ if(NULL == term){
+ mg_profile->mg_stats->total_num_of_find_term_failed_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Subtract request Failed, termination no associated with any context \n");
- /* ERROR - termination didnt bind with requested context */
- mg_util_set_term_string(&errTxt,termId);
- err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
- goto error;
- }
+ "Subtract request Failed, no termination found for input term string[%s] \n", (char*)termId->name.lcl.val);
+ mg_util_set_term_string(&errTxt,termId);
+ err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
+ goto error;
+ }
- if(NULL == term){
+ if(SWITCH_STATUS_FALSE == megaco_context_is_term_present(mg_ctxt, term)){
+ mg_profile->mg_stats->total_num_of_no_term_ctxt_error++;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Subtract request Failed, no termination found for input term string[%s] \n", (char*)termId->name.lcl.val);
- mg_util_set_term_string(&errTxt,termId);
- err_code = MGT_MGCO_RSP_CODE_UNKNOWN_TERM_ID;
- goto error;
- }
+ "Subtract request Failed, termination no associated with any context \n");
+ /* ERROR - termination didnt bind with requested context */
+ mg_util_set_term_string(&errTxt,termId);
+ err_code = MGT_MGCO_RSP_CODE_NO_TERM_CTXT;
+ goto error;
+ }
/* remove termination from context */
megaco_context_sub_termination(mg_ctxt, term);