MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mi_get_stats

Function mi_get_stats

statistics.c:783–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781
782
783static mi_response_t *mi_get_stats(const mi_params_t *params,
784 struct mi_handler *async_hdl)
785{
786 mi_response_t *resp;
787 mi_item_t *resp_obj;
788 mi_item_t *params_arr;
789 int i, j, no_params;
790 int found;
791 module_stats *mods;
792 stat_var *stat;
793 str val;
794
795 resp = init_mi_result_object(&resp_obj);
796 if (!resp)
797 return 0;
798
799 if (get_mi_array_param(params, "statistics", &params_arr, &no_params) < 0) {
800 free_mi_response(resp);
801 return init_mi_param_error();
802 }
803
804 for (i = 0; i < no_params; i++) {
805 if (get_mi_arr_param_string(params_arr, i, &val.s, &val.len) < 0) {
806 free_mi_response(resp);
807 return init_mi_param_error();
808 }
809
810 if ( val.len==3 && memcmp(val.s,"all",3)==0) {
811 /* add all statistic variables */
812 for( j=0 ; j<collector->mod_no ;j++ ) {
813 if (mi_add_module_stats(resp_obj, &collector->amodules[j] )!=0)
814 goto error;
815 }
816
817 found = 1;
818 } else if ( val.len>1 && val.s[val.len-1]==':') {
819 /* add module statistics */
820 val.len--;
821 mods = get_stat_module( &val );
822 if (mods==0)
823 continue;
824 if (mi_add_module_stats(resp_obj, mods)!=0)
825 goto error;
826
827 found = 1;
828 } else {
829 /* add only one statistic */
830 stat = get_stat( &val );
831 if (stat==0)
832 continue;
833 if (mi_add_stat(resp_obj, stat)!=0)
834 goto error;
835
836 found = 1;
837 }
838 }
839
840 if (!found) {

Callers

nothing calls this directly

Calls 10

init_mi_result_objectFunction · 0.85
get_mi_array_paramFunction · 0.85
free_mi_responseFunction · 0.85
init_mi_param_errorFunction · 0.85
get_mi_arr_param_stringFunction · 0.85
mi_add_module_statsFunction · 0.85
get_stat_moduleFunction · 0.85
get_statFunction · 0.85
mi_add_statFunction · 0.85
init_mi_errorFunction · 0.85

Tested by

no test coverage detected