SWITCH_STANDARD_API(status_function)
{
switch_core_time_duration_t duration = { 0 };
- int sps = 0, last_sps = 0;
+ int sps = 0, last_sps = 0, max_sps = 0;
switch_bool_t html = SWITCH_FALSE; /* shortcut to format.html */
char * nl = "\n"; /* shortcut to format.nl */
stream_format format = { 0 };
stream->write_function(stream, "%" SWITCH_SIZE_T_FMT " session(s) since startup%s", switch_core_session_id() - 1, nl);
switch_core_session_ctl(SCSC_LAST_SPS, &last_sps);
switch_core_session_ctl(SCSC_SPS, &sps);
- stream->write_function(stream, "%d session(s) - %d out of max %d per sec %s", switch_core_session_count(), last_sps, sps, nl);
+ switch_core_session_ctl(SCSC_SPS_PEAK, &max_sps);
+ stream->write_function(stream, "%d session(s) - %d out of max %d per sec peak %d %s", switch_core_session_count(), last_sps, sps, max_sps, nl);
stream->write_function(stream, "%d session(s) max%s", switch_core_session_limit(0), nl);
stream->write_function(stream, "min idle cpu %0.2f/%0.2f%s", switch_core_min_idle_cpu(-1.0), switch_core_idle_cpu(), nl);
return SWITCH_STATUS_SUCCESS;
}
-#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]"
+#define CTL_SYNTAX "[recover|send_sighup|hupall|pause [inbound|outbound]|resume [inbound|outbound]|shutdown [cancel|elegant|asap|now|restart]|sps|sps_peak_reset|sync_clock|sync_clock_when_idle|reclaim_mem|max_sessions|min_dtmf_duration [num]|max_dtmf_duration [num]|default_dtmf_duration [num]|min_idle_cpu|loglevel [level]|debug_level [level]]"
SWITCH_STANDARD_API(ctl_function)
{
int argc;
switch_core_session_ctl(SCSC_DEBUG_LEVEL, &arg);
stream->write_function(stream, "+OK DEBUG level: %d\n", arg);
+ } else if (!strcasecmp(argv[0], "sps_peak_reset")) {
+ arg = -1;
+ switch_core_session_ctl(SCSC_SPS_PEAK, &arg);
+ stream->write_function(stream, "+OK max sessions per second counter reset\n");
} else if (!strcasecmp(argv[0], "last_sps")) {
switch_core_session_ctl(SCSC_LAST_SPS, &arg);
stream->write_function(stream, "+OK last sessions per second: %d\n", arg);
switch_core_session_ctl(SCSC_SPS, &int_val);
snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);
break;
+ case SS_PEAK_SESSIONS_PER_SECOND:
+ switch_core_session_ctl(SCSC_SPS_PEAK, &int_val);
+ snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val);
+ break;
default:
snmp_log(LOG_WARNING, "Unregistered OID-suffix requested (%d)\n", (int) subid);
netsnmp_set_request_error(reqinfo, request, SNMP_NOSUCHOBJECT);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Count", "%u", switch_core_session_count());
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Max-Sessions", "%u", switch_core_session_limit(0));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec", "%u", runtime.sps);
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Per-Sec-Max", "%u", runtime.sps_peak);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Session-Since-Startup", "%" SWITCH_SIZE_T_FMT, switch_core_session_id() - 1);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Idle-CPU", "%f", switch_core_idle_cpu());
switch_event_fire(&event);
case SCSC_LAST_SPS:
newintval = runtime.sps_last;
break;
+ case SCSC_SPS_PEAK:
+ if (oldintval == -1) {
+ runtime.sps_peak = 0;
+ }
+ newintval = runtime.sps_peak;
+ break;
case SCSC_MAX_DTMF_DURATION:
newintval = switch_core_max_dtmf_duration(oldintval);
break;