add sps count to the status output
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5804 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
3711220ae5
commit
6d091447b1
|
@ -156,6 +156,7 @@ struct switch_runtime {
|
||||||
switch_mutex_t *throttle_mutex;
|
switch_mutex_t *throttle_mutex;
|
||||||
uint32_t sps_total;
|
uint32_t sps_total;
|
||||||
int32_t sps;
|
int32_t sps;
|
||||||
|
int32_t sps_last;
|
||||||
switch_log_level_t hard_log_level;
|
switch_log_level_t hard_log_level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1008,6 +1008,7 @@ typedef enum {
|
||||||
SCSC_CHECK_RUNNING,
|
SCSC_CHECK_RUNNING,
|
||||||
SCSC_LOGLEVEL,
|
SCSC_LOGLEVEL,
|
||||||
SCSC_SPS,
|
SCSC_SPS,
|
||||||
|
SCSC_LAST_SPS,
|
||||||
SCSC_RECLAIM
|
SCSC_RECLAIM
|
||||||
} switch_session_ctl_t;
|
} switch_session_ctl_t;
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ SWITCH_STANDARD_API(status_function)
|
||||||
uint8_t html = 0;
|
uint8_t html = 0;
|
||||||
switch_core_time_duration_t duration;
|
switch_core_time_duration_t duration;
|
||||||
char *http = NULL;
|
char *http = NULL;
|
||||||
|
int sps, last_sps;
|
||||||
|
|
||||||
if (session) {
|
if (session) {
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
@ -68,7 +69,9 @@ SWITCH_STANDARD_API(status_function)
|
||||||
duration.mms == 1 ? "" : "s");
|
duration.mms == 1 ? "" : "s");
|
||||||
|
|
||||||
stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" sessions since startup\n", switch_core_session_id() - 1 );
|
stream->write_function(stream, "%"SWITCH_SIZE_T_FMT" sessions since startup\n", switch_core_session_id() - 1 );
|
||||||
stream->write_function(stream, "%d sessions\n", switch_core_session_count());
|
switch_core_session_ctl(SCSC_LAST_SPS, &last_sps);
|
||||||
|
switch_core_session_ctl(SCSC_SPS, &sps);
|
||||||
|
stream->write_function(stream, "%d session(s) %d/%d\n", switch_core_session_count(), last_sps, sps);
|
||||||
|
|
||||||
if (html) {
|
if (html) {
|
||||||
stream->write_function(stream, "</b>\n");
|
stream->write_function(stream, "</b>\n");
|
||||||
|
@ -130,6 +133,9 @@ SWITCH_STANDARD_API(ctl_function)
|
||||||
}
|
}
|
||||||
switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
|
switch_core_session_ctl(SCSC_LOGLEVEL, &arg);
|
||||||
stream->write_function(stream, "log level: %s [%d]\n", switch_log_level2str(arg), arg);
|
stream->write_function(stream, "log level: %s [%d]\n", switch_log_level2str(arg), arg);
|
||||||
|
} else if (!strcasecmp(argv[0], "last_sps")) {
|
||||||
|
switch_core_session_ctl(SCSC_LAST_SPS, &arg);
|
||||||
|
stream->write_function(stream, "last sessions per second: %d\n", arg);
|
||||||
} else if (!strcasecmp(argv[0], "sps")) {
|
} else if (!strcasecmp(argv[0], "sps")) {
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
arg = atoi(argv[1]);
|
arg = atoi(argv[1]);
|
||||||
|
|
|
@ -206,7 +206,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
|
||||||
uint32_t current_ms = 0;
|
uint32_t current_ms = 0;
|
||||||
uint32_t x, tick = 0;
|
uint32_t x, tick = 0;
|
||||||
switch_time_t ts = 0;
|
switch_time_t ts = 0;
|
||||||
|
|
||||||
memset(&globals, 0, sizeof(globals));
|
memset(&globals, 0, sizeof(globals));
|
||||||
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
|
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
|
||||||
|
|
||||||
|
@ -229,6 +229,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
|
||||||
}
|
}
|
||||||
switch_mutex_lock(runtime.throttle_mutex);
|
switch_mutex_lock(runtime.throttle_mutex);
|
||||||
|
runtime.sps_last = runtime.sps_total - runtime.sps;
|
||||||
runtime.sps = runtime.sps_total;
|
runtime.sps = runtime.sps_total;
|
||||||
switch_mutex_unlock(runtime.throttle_mutex);
|
switch_mutex_unlock(runtime.throttle_mutex);
|
||||||
tick = 0;
|
tick = 0;
|
||||||
|
|
|
@ -657,6 +657,9 @@ SWITCH_DECLARE(int32_t) switch_core_session_ctl(switch_session_ctl_t cmd, int32_
|
||||||
}
|
}
|
||||||
*val = runtime.hard_log_level;
|
*val = runtime.hard_log_level;
|
||||||
break;
|
break;
|
||||||
|
case SCSC_LAST_SPS:
|
||||||
|
*val = runtime.sps_last;
|
||||||
|
break;
|
||||||
case SCSC_SPS:
|
case SCSC_SPS:
|
||||||
switch_mutex_lock(runtime.throttle_mutex);
|
switch_mutex_lock(runtime.throttle_mutex);
|
||||||
if (*val > 0) {
|
if (*val > 0) {
|
||||||
|
|
Loading…
Reference in New Issue