| 188 | |
| 189 | |
| 190 | int init_pkg_stats(int procs_no) |
| 191 | { |
| 192 | int n; |
| 193 | str n_str; |
| 194 | char *name; |
| 195 | str sname; |
| 196 | group_stats *total_size_grp, *used_size_grp, *real_used_size_grp, |
| 197 | *max_used_size_grp, *free_size_grp, *frags_grp; |
| 198 | |
| 199 | LM_DBG("setting stats for %d processes\n",procs_no); |
| 200 | |
| 201 | pkg_status = shm_malloc(procs_no*sizeof(pkg_status_holder)); |
| 202 | marker_t = shm_malloc(procs_no*sizeof(time_t)); |
| 203 | if (pkg_status==NULL || marker_t==NULL) { |
| 204 | LM_ERR("no more pkg mem for stats\n"); |
| 205 | return -1; |
| 206 | } |
| 207 | memset( pkg_status, 0, procs_no*sizeof(pkg_status_holder)); |
| 208 | memset( marker_t, 0, procs_no*sizeof(time_t)); |
| 209 | no_pkg_status = procs_no; |
| 210 | |
| 211 | |
| 212 | total_size_grp = register_stats_group("proc_total_size"); |
| 213 | if (!total_size_grp) { |
| 214 | LM_ERR("could not register stats group proc_total_size"); |
| 215 | return -1; |
| 216 | } |
| 217 | used_size_grp = register_stats_group("proc_used_size"); |
| 218 | if (!used_size_grp) { |
| 219 | LM_ERR("could not register stats group proc_used_size"); |
| 220 | return -1; |
| 221 | } |
| 222 | real_used_size_grp = register_stats_group("proc_real_used_size"); |
| 223 | if (!real_used_size_grp) { |
| 224 | LM_ERR("could not register stats group proc_real_used_size"); |
| 225 | return -1; |
| 226 | } |
| 227 | max_used_size_grp = register_stats_group("proc_max_used_size"); |
| 228 | if (!max_used_size_grp) { |
| 229 | LM_ERR("could not register stats group proc_max_used_size"); |
| 230 | return -1; |
| 231 | } |
| 232 | free_size_grp = register_stats_group("proc_free_size"); |
| 233 | if (!free_size_grp) { |
| 234 | LM_ERR("could not register stats group proc_free_size"); |
| 235 | return -1; |
| 236 | } |
| 237 | frags_grp = register_stats_group("proc_fragments"); |
| 238 | if (!frags_grp) { |
| 239 | LM_ERR("could not register stats group proc_fragments"); |
| 240 | return -1; |
| 241 | } |
| 242 | |
| 243 | /* build the stats and register them */ |
| 244 | for( n=0 ; n<procs_no ; n++) { |
| 245 | n_str.s = int2str( n, &n_str.len); |
| 246 | |
| 247 | if ( (name=build_stat_name( &n_str,"total_size"))==0 || |
no test coverage detected