/* signal handler for when freeswitch is running in background mode. * signal triggers the shutdown of freeswitch # */ static void handle_SIGILL(int sig) { int32_t arg = 0; if (sig) {}; /* send shutdown signal to the freeswitch core */ switch_core_session_ctl(SCSC_SHUTDOWN, &arg); return; }
int handle_systemStats(netsnmp_mib_handler *handler, netsnmp_handler_registration *reginfo, netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests) { netsnmp_request_info *request = NULL; oid subid; switch_time_t uptime; uint32_t int_val = 0; switch(reqinfo->mode) { case MODE_GET: subid = requests->requestvb->name[reginfo->rootoid_len - 2]; snmp_log(LOG_DEBUG, "systemStats OID-suffix requested (%d)\n", (int) subid); switch (subid) { case SS_UPTIME: uptime = switch_core_uptime() / 10000; snmp_set_var_typed_value(requests->requestvb, ASN_TIMETICKS, (u_char *) &uptime, sizeof(uptime)); break; case SS_SESSIONS_SINCE_STARTUP: int_val = switch_core_session_id() - 1; snmp_set_var_typed_integer(requests->requestvb, ASN_COUNTER, int_val); break; case SS_CURRENT_SESSIONS: int_val = switch_core_session_count(); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); break; case SS_MAX_SESSIONS: switch_core_session_ctl(SCSC_MAX_SESSIONS, &int_val); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); break; case SS_CURRENT_CALLS: { switch_cache_db_handle_t *dbh; char sql[1024] = ""; if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) { return SNMP_ERR_GENERR; } sprintf(sql, "SELECT COUNT(*) FROM calls WHERE hostname='%s'", switch_core_get_switchname()); switch_cache_db_execute_sql_callback(dbh, sql, sql_count_callback, &int_val, NULL); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); switch_cache_db_release_db_handle(&dbh); } break; case SS_SESSIONS_PER_SECOND: switch_core_session_ctl(SCSC_LAST_SPS, &int_val); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); break; case SS_MAX_SESSIONS_PER_SECOND: 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; case SS_PEAK_SESSIONS_PER_FIVEMIN: switch_core_session_ctl(SCSC_SPS_PEAK_FIVEMIN, &int_val); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); break; case SS_PEAK_SESSIONS: switch_core_session_ctl(SCSC_SESSIONS_PEAK, &int_val); snmp_set_var_typed_integer(requests->requestvb, ASN_GAUGE, int_val); break; case SS_PEAK_SESSIONS_FIVEMIN: switch_core_session_ctl(SCSC_SESSIONS_PEAK_FIVEMIN, &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); } break; default: /* we should never get here, so this is a really bad error */ snmp_log(LOG_ERR, "Unknown mode (%d) in handle_systemStats\n", reqinfo->mode); return SNMP_ERR_GENERR; } return SNMP_ERR_NOERROR; }