What is Stress Testing ?
It is the process of putting so great load on the system and measuring its response. It helps to determine the maximum operating capacity of the system. The behaviour of the system will be predictable under high/peak loads.
I will mention some tools which help you in the testing of OpenSIPS SIP server under stress.
Using SIP traffic generator , we can highly load the SIP server and read the statistics. For example under certain high load, the number of dropped packets became unacceptable or the number of SIP transactions that are in use in memory is so large.
It is shell script and it is used as management and monitoring tool. It has some options to generate some statistics. This script communicates with OpenSIPS server through either FIFO pipe or unix socket (The control engine is either fifo or unixsocket). The script is present in OpenSIPS sbin directory. Its configuration file opensipsctlrc is stored in OpenSIPS etc directory. Check the name of your fifo file in the configuration file. To display the available commands, type: #./opensipsctl fifo which
Here is a list of commands available in OpenSIPS 1.11.
get_statistics, reset_statistics, uptime, version, pwd, arg, which, ps, kill, debug, cache_store, cache_fetch, cache_remove, event_subscribe, events_list, subscribers_list, list_tcp_conns, help, list_blacklists, t_uac_dlg, t_uac_cancel, t_hash, t_reply, ul_rm, ul_rm_contact, ul_dump, ul_flush, ul_add, ul_show_contact, ul_sync, dlg_list, dlg_list_ctx, dlg_end_dlg, dlg_db_sync, dlg_restore_db, profile_get_size, profile_list_dlgs, profile_get_values, list_all_profiles.
- For example to execute the command “ps”, type: #./opensipsctl fifo ps. This command display all processes running by OpenSIPS. The output looks like:
Process:: ID=0 PID=9739 Type=attendant
Process:: ID=1 PID=9747 Type=MI FIFO
Process:: ID=2 PID=9749 Type=SIP receiver udp:10.0.0.9:5060
Process:: ID=3 PID=9751 Type=SIP receiver udp:10.0.0.9:5060
Process:: ID=4 PID=9753 Type=SIP receiver udp:10.0.0.9:5060
Process:: ID=5 PID=9755 Type=SIP receiver udp:10.0.0.9:5060
Process:: ID=6 PID=9756 Type=time_keeper
Process:: ID=7 PID=9757 Type=timer: tm-utimer
Process:: ID=8 PID=9760 Type=TCP receiver
Process:: ID=9 PID=9762 Type=TCP receiver
Process:: ID=10 PID=9764 Type=TCP receiver
Process:: ID=11 PID=9765 Type=TCP receiver
Process:: ID=12 PID=9768 Type=TCP main
- To get the number of simultaneous calls (=dialogs in case no presence), type: #./opensipsctl fifo get_statistics dialog. Both SIP INVITE message (Establishing a Call) and SUBSCRIBE message (subscription to presence service) creates dialog. If the SIP server provides call management + presence, the number of active dialogs will not be equal to the number of calls. The length of the call affects the memory of the SIP server not the processing because the dialog remains in the memory till one of the end parties (caller or calle) ends the dialog by sending SIP BYE message.
- To take information about specific command, use “help” command with the name of the command as an argument. For example if you want to take information about the command “ps”, type: #./opensipsctl fifo help ps. The output looks like:
Help:: lists all processes used by OpenSIPS
Exported by:: core
Note: Current opensipsctl does not support NoSQL databases.
OpenSIPS Control Panel (OpenSIPS-CP)
You can also use OpenSIPS control panel (OpenSIPS-CP) to do the same things. Open the web interface. Click on “System” –> “MI Commands”. Choose a command from the command list and press “Enter”. Dont forget the parameters.
OpenSIPS-CP Statistics Monitor Page
- There are two tables needed for statistics monitoring in OpenSIPS-CP. Do the following to download the structures of monitored_stats and monitoring_stats tables in mysql opensips database:
#mysql -Dopensips -p < config/tools/system/smonitor/tables.mysql
- On the web interface, click on “System” –> “Statistics Monitor”. You will get the following:
For example you can get some real time statistics about transaction module (TM) by clicking on the corresponding item in the list “Module:tm”. The “inuse_transaction” sub-item gives the number of transactions in use in memory. The transactions should be released quickly and the average value of this number should be stable (transactions created and released quickly). The number of transactions per second defines the performance of SIP proxy.
Also you can get statistics on the number of TCP/UDP packets which waiting to be processed. By clicking on “Module:net” item, you can see “waiting_udp” and “waiting_tcp” sub-items.
- Edit the cron_job/get_opensips_stats.php file and check the value of the variable $path_to_smonitor if it is correct according to your opensips-cp.
- Add a cron job that collects data from the opensips:
# crontab -e
Append the following entry:
* * * * * root php /var/www/opensips-cp/cron_job/get_opensips_stats.php > /dev/null
The MI exported functions can be called only if the corresponded modules are loaded. Otherwise you will get an error message (command not available). For example enabling tracing by calling sip_trace (# ./opensipsctl fifo sip_trace on) will not work if the module “siptrace.so” is not loaded (i.e. configured to be loaded in the configuration file). You will get this error message “500 command ‘sip_trace’ not available”.
Module Not loaded –> No Exported Functions –> Error upon calling “not exist” Function
The Next Part will be about SIPSAK command line tool which is used as a SIP traffic generator to test the performance and the security of the SIP servers or user agents.