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

Function fs_renew_stats

modules/freeswitch/fs_proc.c:131–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131int fs_renew_stats(fs_evs *sock, const cJSON *ev)
132{
133 fs_stats stats;
134 char *s, *end;
135
136 memset(&stats, 0, sizeof stats);
137
138 s = cJSON_GetObjectItem((cJSON *)ev, "Idle-CPU")->valuestring;
139 stats.id_cpu = strtof(s, &end);
140 if (*end) {
141 LM_ERR("bad Idle-CPU: %s\n", s);
142 return -1;
143 }
144
145 s = cJSON_GetObjectItem((cJSON *)ev, "Session-Count")->valuestring;
146 stats.sess = strtol(s, &end, 0);
147 if (*end) {
148 LM_ERR("bad Session-Count: %s\n", s);
149 return -1;
150 }
151
152 s = cJSON_GetObjectItem((cJSON *)ev, "Max-Sessions")->valuestring;
153 stats.max_sess = strtol(s, &end, 0);
154 if (*end) {
155 LM_ERR("bad Max-Sessions: %s\n", s);
156 return -1;
157 }
158
159 stats.valid = 1;
160
161 LM_DBG("FS stats (%s:%d), idle cpu: %.3f, sessions: %d/%d\n%s\n",
162 sock->host.s, sock->port, stats.id_cpu, stats.sess, stats.max_sess,
163 sock->handle->last_sr_event->body);
164
165 lock_start_write(sock->stats_lk);
166 sock->stats = stats;
167 lock_stop_write(sock->stats_lk);
168
169 return 0;
170}
171
172int fs_raise_event(fs_evs *sock, const char *name, const char *body)
173{

Callers 1

handle_ioFunction · 0.85

Calls 1

cJSON_GetObjectItemFunction · 0.50

Tested by

no test coverage detected