Monitoring and reporting 3G radio signal-strength (RSSI, dBm) on Mikrotik Routerboards

Monitoring a large number of Mikrotik Routerboards is easy using software and tools like LibreNMS and Oxidized, but it is unfortunately not possible to retrieve values for 3G/4G/etc signal-strength RSSI (in dBm) via SNMP when using interfaces like the Sierra MC8705 Mini-PCIe card.

However, using some RouterOS scripts, we can read and push the value for signal strength to a remote listening server using HTTP GET requests. In my case, the server is running Mango Automation software, which also handles the historising, trending and event-detection handling.

3g-signal

Because of some limitations in the way that both globally declared functions and the /interface ppp-client get info command work inside RouterOS, we need to wrap one script inside another, using the wrapper script to both start and then kill the background get-info command (if we don’t kill it, we can’t invoke it again without rebooting). So in total, there are three parts to this method:

  1. A script to run the ppp ‘get-info’ command, opening a serial session to the card, parsing out the value and loading it into a RouterOS global variable.
  2. Another script to form this value into a HTTP GET request, pushing it to the remote server
  3. A scheduler that runs the wrapper script periodically.

Note that in the example below, the SITE variable is used as a globally unique identifier for the transmitting station. This comes into play when we configure the listening data source – we need a way to determine which station is sending the RSSI value.

Get-signal script:

 #runs ppp-info to grab the 3G signal strength
 #and loads this into a global var
 #don't run this script by itself, only via push-signal script!
 /interface ppp-client info ppp-out1 do={
 :global RSSI $"signal-strengh";
 }

Note: the mis-spelling of “signal-strengh” is not a typo, at least not by me! This is actually the way that the value is spelt in RouterOS! Expect that it may be changed in later versions.

Push-signal script:

:global URL http://your-mango-server/httpds
 :global SITE unique-site-identifier
 #No need to edit below this line.
 :global RSSI
 :global bar
 #use execute to run concurrently then kill the job
 execute script="get-signal"
 delay 5
 /system script job remove [find script=get-signal]
 #truncate to the signal integer
 set bar {:put [:pick $RSSI 0 [:find $RSSI " "]]}
 /tool fetch url="$URL\3F$SITE=$bar"

To run the script/s, we just add a scheduler job:

/system scheduler add interval=5m name=push-signal on-event=push-signal

Mango Automation Listener Configuration

Add a ‘HTTP data source’ listener with default settings. If you’re running Mango on a port other than 80, you’d need to adjust the :global URL variable in the mikrotik script accordingly.

The Mango datapoint JSON configuration is as follows:

{
 "dataPoints":[
 {
 "xid":"DP_680193",
 "name":"Mikrotik 3G Signal Strength",
 "enabled":true,
 "loggingType":"ALL",
 "intervalLoggingPeriodType":"MINUTES",
 "intervalLoggingType":"INSTANT",
 "purgeType":"YEARS",
 "pointLocator":{
 "dataType":"NUMERIC",
 "binary0Value":"",
 "parameterName":"unique-site-identifier",
 "setPointName":"",
 "settable":false
 },
 "eventDetectors":[
 ],
 "plotType":"STEP",
 "unit":"",
 "chartColour":"",
 "chartRenderer":null,
 "dataSourceXid":"XID-of-your-listener-datasource",
 "defaultCacheSize":1,
 "deviceName":"unique-site-identifier",
 "discardExtremeValues":false,
 "discardHighLimit":0.0,
 "discardLowLimit":0.0,
 "intervalLoggingPeriod":15,
 "intervalLoggingSampleWindowSize":0,
 "overrideIntervalLoggingSamples":false,
 "purgeOverride":false,
 "purgePeriod":1,
 "textRenderer":{
 "type":"ANALOG",
 "useUnitAsSuffix":false,
 "unit":"",
 "renderedUnit":"",
 "suffix":" dBm",
 "format":"##"
 },
 "tolerance":0.0
 }
 ]
}

One consideration when doing this: if your 3G signal drops too low, you won’t be able to push the value to the remote server, and the measurement will be lost!  A quick and dirty way to log these in the routerboard itself could be to add these lines (untested) to the push-signal script:

:if ($bar > -85) do={
} else={
       :log info "RSSI is $RSSI."
}

Here’s what a trend for a single radio looks like after three months or so:

3g-signal-single

 

If this post helped you, please leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *