From openSIPS

Documentation: Management Interface - 3.3

Documentation -> Manuals -> Manual devel -> Management Interface

Pages for other versions: devel 3.2 3.1 Older versions: 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


Management Interface v3.3
PrevNext

The Management Interface (or MI) is an OpenSIPS interface that allows external applications to trigger predefined commands inside OpenSIPS.

Overview

Such commands typically allows an external app to :

  1. push data into OpenSIPS (like setting debug level, registering a contact, etc)
  2. fetch data from OpenSIPS (see registered users, see ongoing calls, get statistics, etc)
  3. trigger an internal action in OpenSIPS (reloading data, sending a message, etc)

The MI commands are provided by the OpenSIPS core (see full list) and also by modules (check the commands provided by each module).


Protocols

The protocols available in order to connect (from external apps) to the OpenSIPS MI are JSON-RPC over several transports and XML-RPC. While the interface itself (tailored around the JSON format) is provided by the OpenSIPS core, each actual transport protocol is provided by a separate OpenSIPS module. You can load multiple MI modules in order to use multiple MI transport protocols at the same time.

The majority of the MI backend modules only provide the transport, while the command parsing and response formatting (as JSON-RPC) is done by the OpenSIPS core. The only exceptions are the mi_html and mi_xmlrpc_ng modules, which use a different format.

The available MI modules are :

All protocols do allow multiple applications (clients) to connect at the same time to the MI interface.


Examples

A few examples of JSON-RPC calls for OpenSIPS:

# Request with no parameters:
{
  "jsonrpc": "2.0",
  "method": "ps",
  "id": 10
}

# Response:
{
  "jsonrpc":  "2.0",
  "result": {
    "Processes":  [{
        "ID": 0,
        "PID":  9467,
        "Type": "attendant"
      }, {
        "ID": 1,
        "PID":  9468,
        "Type": "HTTPD 127.0.0.1:8008"
      }, {
        "ID": 3,
        "PID":  9470,
        "Type": "time_keeper"
      }, {
        "ID": 4,
        "PID":  9471,
        "Type": "timer"
      }, {
        "ID": 5,
        "PID":  9472,
        "Type": "SIP receiver udp:127.0.0.1:5060 "
      }, {
        "ID": 7,
        "PID":  9483,
        "Type": "Timer handler"
      }, ]
  },
  "id": 10
}

# Request with positional parameters:
{
  "jsonrpc": "2.0",
  "method": "log_level",
  "params": [4, 9472],
  "id": 11
}

# Request with named parameters:
{
  "jsonrpc": "2.0",
  "method": "log_level",
  "params": {
    "level": 4,
    "pid": 9472
  },
  "id": 11
}

# Request with an array type of parameter:
{
  "jsonrpc": "2.0",
  "method": "get_statistics",
  "params": {
    "statistics": ["shmem:", "core:"]
  },
  "id": 11
}

A simple example of interacting with OpenSIPS via MI interfaces is the opensips-cli utility - it uses FIFO to push MI commands into OpenSIPS:

    opensips-cli -x mi ps
    opensips-cli -x mi log_level 4 9472

Example of sending a JSON-RPC OpenSIPS MI command from the command-line, using curl:

$ curl -X POST localhost:8888/mi -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": "1", "method": "ps"}'
Retrieved from https://www.opensips.org/Documentation/Interface-MI-3-3
Page last modified on August 24, 2021, at 11:41 AM