Documentation

Documentation.Interface-MI-3-3 History

Hide minor edits - Show changes to markup

August 24, 2021, at 11:41 AM by liviu -
Changed line 133 from:

A simple program in Python to run a MI command in OpenSIPs via XMLRPC protocol:

to:

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

Changed lines 135-138 from:
  1. !/usr/bin/python

import xmlrpclib opensips = xmlrpclib.ServerProxy('http://127.0.0.1:8080/RPC2') print opensips.ps();

to:

$ curl -X POST localhost:8888/mi -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": "1", "method": "ps"}'

June 23, 2021, at 06:39 PM by razvancrainea -
Added lines 45-46:
  • mi_script - provides the ability to run MI commands directly from OpenSIPS' script, returning the result as a JSON string.
Changed lines 126-127 from:

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

to:

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

Changed lines 129-130 from:
    opensipsctl fifo ps
    opensipsctl fifo log_level 4 9472
to:
    opensips-cli -x mi ps
    opensips-cli -x mi log_level 4 9472
April 16, 2019, at 08:52 PM by liviu -
Changed line 26 from:
to:

February 01, 2019, at 05:43 PM by rvlad_patrascu -
Changed lines 29-40 from:

Several protocols are available in order to connect (from external apps) to the OpenSIPS MI . While the interface itself is provided by OpenSIPS core, each protocol is provided by a separate OpenSIPS module. You can load multiple MI modules in order to use multiple MI protocols in the same time.

Available protocols are :

  • mi_fifo - protocol is text oriented (see the syntax in the module documentation), communications is done via a FIFO file; OpenSIPS reads from a predefined FIFO file, where the external apps are writing down the MI commands. As the file is actually as stream of data, there is no restrictions here on the amount of data OpenSIPS may return (when fetching data from OpenSIPS)
  • mi_datagram - protocol is text oriented, similar for fifo (see the syntax in the module documentation), communication is done either via UNIX SOCKETS , either via UDP packages ; OpenSIPS listens for MI commands on UDP port(s) or unisock files; The transported data is limited to the size of a Datagram (65K).
  • mi_xmlrpc - protocol is XMLRPC (XML over HTTP). As TCP is used, there is no limit in regards to the amount of transfered data.

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

to:

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 :

  • mi_fifo - provides JSON-RPC transport via a FIFO file; OpenSIPS reads from a predefined FIFO file, where the external apps are writing down the MI commands. As the file is actually as stream of data, there is no restrictions here on the amount of data OpenSIPS may return (when fetching data from OpenSIPS).
  • mi_datagram - provides JSON-RPC transport either via UNIX SOCKETS, or via UDP packets; OpenSIPS listens for MI commands on UDP port(s) or unisock files; The transported data is limited to the size of a Datagram (65K).
  • mi_http - provides JSON-RPC transport over HTTP. As TCP is used, there is no limit in regards to the amount of transfered data.
  • mi_html- provides a way of issuing MI commands directly from a web browser via an HTML page. The command's parameters are passed in the URL's query string. Although not conforming to JSON-RPC, the MI responses are still delivered in JSON format within the page.
  • mi_xmlrpc_ng - implements XML-RPC by not only providing an HTTP transport but also by translating between the MI's internal JSON format and XML.

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

Changed lines 51-54 from:

A simple example of interacting with OpenSIPS via MI interfaces is when using the opensipsctl utility - it uses FIFO or XMLRPC protocols to push MI commands into OpenSIPS.

The 'opensipsctl utility allows you explicitly run an MI command via the FIFO file:

to:

A few examples of JSON-RPC calls for OpenSIPS:

Changed lines 54-56 from:
    opensipsctl fifo _mi_cmd_
    opensipsctl fifo ps
    opensipsctl fifo debug 4
to:
  1. Request with no parameters:

{

  "jsonrpc": "2.0",
  "method": "ps",
  "id": 10

}

  1. 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

}

  1. Request with positional parameters:

{

  "jsonrpc": "2.0",
  "method": "log_level",
  "params": [4, 9472],
  "id": 11

}

  1. Request with named parameters:

{

  "jsonrpc": "2.0",
  "method": "log_level",
  "params": {
    "level": 4,
    "pid": 9472
  },
  "id": 11

}

  1. Request with an array type of parameter:

{

  "jsonrpc": "2.0",
  "method": "get_statistics",
  "params": {
    "statistics": ["shmem:", "core:"]
  },
  "id": 11

}

Changed lines 124-126 from:

or it internally and transparently uses MI command them when providing different or more complex functionalities.

A simple program in Python to trigger to run a MI command in OpenSIPs via XMLRPC protocol:

to:

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

    opensipsctl fifo ps
    opensipsctl fifo log_level 4 9472

A simple program in Python to run a MI command in OpenSIPs via XMLRPC protocol:

October 10, 2014, at 01:16 PM by liviu -
Changed line 4 from:

(:allVersions Interface-MI 3.3:)

to:

(:allVersions Interface-MI 3.3 :)

March 20, 2014, at 08:54 PM by razvancrainea -
Changed line 23 from:

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

to:

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

March 20, 2014, at 08:53 PM by razvancrainea -
Added lines 1-63:
Documentation -> Manuals -> Manual 3.3 -> Management Interface

(:title Management Interface - 3.3:)


(:allVersions Interface-MI 3.3:)


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

Several protocols are available in order to connect (from external apps) to the OpenSIPS MI . While the interface itself is provided by OpenSIPS core, each protocol is provided by a separate OpenSIPS module. You can load multiple MI modules in order to use multiple MI protocols in the same time.

Available protocols are :

  • mi_fifo - protocol is text oriented (see the syntax in the module documentation), communications is done via a FIFO file; OpenSIPS reads from a predefined FIFO file, where the external apps are writing down the MI commands. As the file is actually as stream of data, there is no restrictions here on the amount of data OpenSIPS may return (when fetching data from OpenSIPS)
  • mi_datagram - protocol is text oriented, similar for fifo (see the syntax in the module documentation), communication is done either via UNIX SOCKETS , either via UDP packages ; OpenSIPS listens for MI commands on UDP port(s) or unisock files; The transported data is limited to the size of a Datagram (65K).
  • mi_xmlrpc - protocol is XMLRPC (XML over HTTP). As TCP is used, there is no limit in regards to the amount of transfered data.

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


Examples

A simple example of interacting with OpenSIPS via MI interfaces is when using the opensipsctl utility - it uses FIFO or XMLRPC protocols to push MI commands into OpenSIPS.

The 'opensipsctl utility allows you explicitly run an MI command via the FIFO file:

    opensipsctl fifo _mi_cmd_
    opensipsctl fifo ps
    opensipsctl fifo debug 4

or it internally and transparently uses MI command them when providing different or more complex functionalities.

A simple program in Python to trigger to run a MI command in OpenSIPs via XMLRPC protocol:

#!/usr/bin/python
import xmlrpclib
opensips = xmlrpclib.ServerProxy('http://127.0.0.1:8080/RPC2')
print opensips.ps();

Page last modified on August 24, 2021, at 11:41 AM