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

Function w_mi_list_stats_1

statistics.c:873–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871}
872
873static mi_response_t *w_mi_list_stats_1(const mi_params_t *params,
874 struct mi_handler *async_hdl)
875{
876 mi_response_t *resp;
877 mi_item_t *resp_obj;
878 mi_item_t *params_arr;
879 int i, no_params;
880 int found;
881 module_stats *mods;
882 stat_var *stat;
883 str val;
884
885 resp = init_mi_result_object(&resp_obj);
886 if (!resp)
887 return 0;
888
889 if (get_mi_array_param(params, "statistics", &params_arr, &no_params) < 0) {
890 free_mi_response(resp);
891 return init_mi_param_error();
892 }
893
894 for (i = 0; i < no_params; i++) {
895 if (get_mi_arr_param_string(params_arr, i, &val.s, &val.len) < 0) {
896 free_mi_response(resp);
897 return init_mi_param_error();
898 }
899
900 if ( val.len>1 && val.s[val.len-1]==':') {
901 /* add module statistics */
902 val.len--;
903 mods = get_stat_module( &val );
904 if (mods==0)
905 continue;
906 if (mi_list_module_stats(resp_obj, mods)!=0)
907 goto error;
908
909 found = 1;
910 } else {
911 /* add only one statistic */
912 stat = get_stat( &val );
913 if (stat==0)
914 continue;
915 if (mi_list_stat(resp_obj,NULL, stat)!=0)
916 goto error;
917
918 found = 1;
919 }
920 }
921
922 if (!found) {
923 free_mi_response(resp);
924 return init_mi_error(404, MI_SSTR("Statistics Not Found"));
925 }
926
927 return resp;
928
929error:
930 free_mi_response(resp);

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
get_stat_moduleFunction · 0.85
mi_list_module_statsFunction · 0.85
get_statFunction · 0.85
mi_list_statFunction · 0.85
init_mi_errorFunction · 0.85

Tested by

no test coverage detected