Appendix D: Monitoring via the REST API

The Routing Suite Daemon supports a REST API to allow remote monitoring of the Router. The REST API is accessed over HTTP and delivers a JSON payload. The JSON payload is identical to the payload delivered when the local API is called. The REST API is Read-Only so a connecting client can only query state in the Router, never change it.

Local Connection within a Router

Here we are on router R01 and we use the Routing Suite Client to retrieve local state within R01. The JSON is delivered via a local Unix Domain Socket.

flock@R01:~$ flockrsc ribv4 --prefix

Remote Connection from one Router to another

From R01 we can view information on another router using the REST API. The JSON is delivered via HTTP. The command is the same, except we append the host name / IP Address of the target router.

flock@R01:~$ flockrsc ribv4 --prefix --host R02

Remote Connection from Host to any Router

Lets move to a host H01 that is connected to the network. We can install only the Routing Suite Client, and we can monitor all routers, without running the Routing Suite Daemon. NB: This is the flockrsc package being installed, which only includes the Client, not the flockrsd package which includes the Client and the Daemon.

flock@H01# dpkg -i flockrsc_20.0.x_amd64.deb
flock@H01:~$ flockrsc ribv4 --prefix --host R01
flock@H01:~$ flockrsc ribv4 --prefix --host R02

Remote Connection your way

Since the REST API is simply a JSON payload inside HTTP, there are many ways to connect. The Host Operating System can be your choice of Linux, Windows, Mac, Redox, etc. The HTTP client application can be any one that the Operating System supports. For instance, the venerable curl will run on all the above Operating Systems.

To use curl you just need to know the URL to connect to. If you run the Flock Client with the --show-url option, then the URL associated with that command will be displayed rather than connected to.

flock@H01:~$ flockrsc ribv4 --prefix --host R01 --show-url
REST API URL would be 'http://R01:8000/ribv4/prefix'

you@your-host:~$ curl -s -X GET "http://R01:8000/ribv4/prefix"

You can then use the language of your choice to consume and manipulate the JSON information. When feeding into a program we want vanilla JSON (rather than the default of JSON with extra line breaks), so we include the --json option to discover the URL.

flock@H01:~$ flockrsc ribv4 --prefix --json --host R01 --show-url
REST API URL would be 'http://R01:8000/ribv4/prefix/json'

you@your-host:~$ curl -s -X GET "http://R01:8000/ribv4/prefix/json" | python -m json.tool
        "ip_net": "",
        "next_hops": [
                "intf_id": 5,
                "ip_addr": ""
        "origin": "Kernel"

Example: Connecting to the REST API using Python

flock@H01:~$ flockrsc ribv4 -p --host r02 --json --show-url
REST API URL would be 'http://r02:8000/ribv4/prefix/json'

you@your-host:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r = requests.get('http://r02:8000/ribv4/prefix/json')
>>> r.json()
[{'ip_net': '', 'origin': 'Ospfv2', 'next_hops': [{'intf_id': 2, 'ip_addr': ''}, {'intf_id': 4, 'ip_addr': ''}]}, {'ip_net': '', 'origin': 'Kernel', 'next_hops': [{'intf_id': 2}]}, {'ip_net': '', 'origin': 'Ospfv2', 'next_hops': [{'intf_id': 2, 'ip_addr': ''}, {'intf_id': 4, 'ip_addr': ''}]}]

Commonly used REST API URLs

As discussed above the available REST API URL's can be discovered using the Routing Suite Client --show-url option. The URL's mirror the Routing Suite Client long options, for example:

flockrsc ribv4 --prefix maps to the URL /ribv4/prefix

For convenience some commonly used URL's are listed below.


Append /json if you want vanilla JSON (no extra line breaks)


Append /json-pretty if you want JSON pretty printed