Documentation |
Documentation -> Manuals -> Manual 3.2 -> Core MI FunctionsPages for other versions: devel 3.5 3.4 Older versions: 3.3 3.2 3.1 3.0 2.4 2.3 2.2 2.1 1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4
Table of Content (hide)
MI (management interface) functions which are exported by OpenSIPS core. 1. argReturns the full list of arguments used when OpenSIPS was started. As in UNIX, the first argument is the name of executable binary. Example of usage: # opensips-cli -x mi arg [ "./opensips", "-f", "/etc/openser/test.cfg" ] 2. killThe command will terminate OpenSIPS (and internal shutdown). Examples of usage: # opensips-cli -x mi kill 3. list_blacklistsThe command lists all the defined (static or learned) blacklists from OpenSIPS. Examples of usage: # opensips-cli -x mi list_blacklists 4. list_tcp_connsThe command lists all ongoing TCP/TLS connection from OpenSIPS. Examples of usage: # opensips-cli -x mi list_tcp_conns 5. log_level [level] [pid]Get or set the logging level of one or all OpenSIPS processes. If no argument is passed to the log_level command, it will print a table with the current logging levels of all processes. If a logging level is given, it will be set for each process. If pid is also given, the logging level will change only for that process.
Examples of usage: # opensips-cli -x mi log_level { "Processes": [ { "PID": 10670, "Log level": 2, "Type": "attendant" }, { "PID": 10672, "Log level": 3, "Type": "MI FIFO" }, { "PID": 10673, "Log level": 1, "Type": "SIP receiver udp:193.268.3.233:5060" }, ] } # opensipsctl fifo log_level 1 { "New global log level": 1 } # opensipsctl fifo log_level 4 10670 { "Log level": 1 } 6. psThe command will list all all OpenSIPS processes, along with type and description. Examples of usage: # opensips-cli -x mi ps { "Processes": [ { "ID": 0, "PID": 27271, "Type": "attendant" }, { "ID": 1, "PID": 27272, "Type": "MI FIFO" }, { "ID": 2, "PID": 27273, "Type": "time_keeper" }, { "ID": 3, "PID": 27274, "Type": "timer" }, { "ID": 4, "PID": 27275, "Type": "SIP receiver udp:127.0.0.1:5060" }, { "ID": 5, "PID": 27276, "Type": "Timer handler" } ] } 7. pwdPrints the working directory of OpenSIPS instance. Examples of usage: # opensips-cli -x mi pwd { "WD": "/" } 8. reload_routesTriggers the reload of the routing block (the routes) from the script during the runtime.
Arguments: none Please note that there are some limitations of when a reload is possible or not. Depending on the initial configuration of your modules, the reload may be rejected as the usage of the functions in the new script is not compatible with the original module setting and initialization. 9. uptimePrints various time information about OpenSIPS - when it started to run, for how long it runs. Examples of usage: # opensips-cli -x mi uptime { "Now": "Mon Jul 21 17:41:03 2008", "Up since": "Mon Jul 21 17:36:33 2008", "Up time": "270 [sec]" } 10. versionPrints the version string of a runningOpenSIPS. Examples of usage: # opensips-cli -x mi version { "Server": "OpenSIPS (3.2.0-dev (x86_64/linux))" } 11. whichPrints all available MI commands from the queried OpenSIPSinstance. Examples of usage: # opensips-cli -x mi which [ "get_statistics", "list_statistics", "reset_statistics", "uptime", "version", "pwd", "arg", "which", "ps", "kill", "log_level", "xlog_level", "shm_check", "cache_store", "cache_fetch", "cache_remove", "event_subscribe", "events_list", ... 12. get_statisticsPrints the statistics (all, group or one) realtime values.
Output: an object containing the names and values of statistic variables. Examples of usage: # opensips-cli -x mi get_statistics rcv_requests { "core:rcv_requests": 35243 } # opensipsc-cli -x mi get_statistics shmem: { "shmem:total_size": 1073741824, "shmem:max_used_size": 3389232, "shmem:free_size": 1070352592, "shmem:used_size": 2808952, "shmem:real_used_size": 3389232, "shmem:fragments": 3769 } # opensips-cli -x mi get_statistics shmem: core: .... 13. list_statisticsPrints a list of available statistics in the current configuration of OpenSIPS. Arguments:
Examples of usage: # opensips-cli -x mi list_statistics { "shmem:total_size": "non-incremental", "shmem:max_used_size": "non-incremental", "shmem:free_size": "non-incremental", "shmem:used_size": "non-incremental", "shmem:real_used_size": "non-incremental", "shmem:fragments": "non-incremental", "rpmem:rpm_total_size": "non-incremental", "rpmem:rpm_used_size": "non-incremental", ... 14. reset_statisticsReset (to zero) the value of a statistic variable. Note that not all variables allow reset (depending of the nature of the information they carry - example "shmem:used_size").
Output: none. Examples of usage: # opensips-cli -x mi get_statistics received_replies { "tm:received_replies": 14543 } # opensips-cli -x mi reset_statistics received_replies # opensips-cli -x mi get_statistics received_replies { "tm:received_replies": 0 } 15. cache_storeThis command stores in a cache system a string value.
Output: none. # opensips-cli -x mi cache_store local password_user1 password 16. cache_fetchThis command queries for a stored value.
Output: object containing the value if a record is found or 'Value not found' string otherwise. # opensips-cli -x mi cache_fetch local password_user1 17. cache_removeThis command removes a record from the cache system.
Output: None. # opensips-cli -x mi cache_remove local password_user1 18. event_subscribeSubscribes an external application to a certain event.
Output: None. # opensips-cli -x mi event_subscribe E_PIKE_BLOCKED udp:127.0.0.1:8888 1200 19. events_listLists all the events published through the Event Interface. # opensips-cli -x mi events_list { "Events": [ { "name": "E_CORE_THRESHOLD", "id": 0 }, { "name": "E_CORE_SHM_THRESHOLD", "id": 1 }, { "name": "E_CORE_PKG_THRESHOLD", "id": 2 }, ... 20. raise_eventRaises an event through the Event Interface using an MI command.
Output: None. # opensips-cli -x mi raise_event E_PIKE_BLOCKED 127.0.0.1 # array mode # opensips-cli -x -- mi -j raise_event event=E_PIKE_BLOCKED params='{"ip":"127.0.0.1"}' # json mode 21. subscribers_listLists information about the subscribers
Output: If no parameter is specified, then the command returns information about all events and their subscribers. If the event is specified, only the external applications subscribed for that event are returned. If the socket is also specified, only one subscriber information is returned. # opensips-cli -x mi subscribers_list { "Events": [{ "name": "E_RTPPROXY_STATUS", "id": 1, "subscribers": [ ... ] }, { "name": "E_PIKE_BLOCKED", "id": 2, "subscribers": [ ... ] } ] } # opensips-cli -x mi subscribers_list E_RTPPROXY_STATUS { "Event": { "name": "E_RTPPROXY_STATUS", "id": 1, "subscribers": [{ "socket": "unix:/tmp/event.sock", "expire": "never", }, { "socket": "udp:127.0.0.1:8888", "expire": 1100 } ] } } # opensips-cli -x mi subscribers_list E_RTPPROXY_STATUS unix:/tmp/event.sock { "Event": { "name": "E_RTPPROXY_STATUS", "id": 1, "Subscriber": { "socket": "unix:/tmp/event.sock", "expire": "never" } } } 22. mem_pkg_dumpTriggers a pkg memory dump for a given process. The memory dump will written to OpenSIPS's log (syslog or stderr) using the 'memdump' logging level. The global 'memdump' log level may be overwritten by a custom value provided as argument to this command.
Output: None. # opensips-cli -x mi mem_pkg_dump 11854 -1 The processes without IPC support (like timer and per-module processes) will not be able to generate a memory dump. 23. mem_shm_dumpTriggers a shm memory dump. The memory dump will written to OpenSIPS's log (syslog or stderr) using the 'memdump' logging level. The global 'memdump' log level may be overwritten by a custom value provided as argument to this command.
Output: None. # opensips-cli -x mi mem_shm_dump -1 24. shm_checkOnly available with QM_MALLOC + DBG_MALLOC. Fully scans the shared memory pool in order to locate any inconsistencies. If any sign of memory corruption is detected, OpenSIPS will immediately abort. # opensips-cli -x mi shm_check 25. xlog_level [level]Get or set the global xlogging level in OpenSIPS processes. If no argument is passed to the xlog_level command, it will print the current xlog_level. If a logging level is given, it will be globally set for all OpenSIPS processes.
Example of usage: # opensips-cli -x mi xlog_level -2 |