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.
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:
- 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.
- Another script to form this value into a HTTP GET request, pushing it to the remote server
- 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:
1 2 3 4 5 6 |
#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:
1 2 3 4 5 6 7 8 9 10 11 12 |
:global URL http://<span style="color: #ff0000;">your-mango-server</span>/httpds :global SITE <span style="color: #ff0000;">unique-site-identifier</span> #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:
1 |
/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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
{ "dataPoints":[ { "xid":"DP_680193", "name":"Mikrotik 3G Signal Strength", "enabled":true, "loggingType":"ALL", "intervalLoggingPeriodType":"MINUTES", "intervalLoggingType":"INSTANT", "purgeType":"YEARS", "pointLocator":{ "dataType":"NUMERIC", "binary0Value":"", "parameterName":"<span style="color: #ff0000;">unique-site-identifier</span>", "setPointName":"", "settable":false }, "eventDetectors":[ ], "plotType":"STEP", "unit":"", "chartColour":"", "chartRenderer":null, "dataSourceXid":"<span style="color: #ff0000;">XID-of-your-listener-datasource</span>", "defaultCacheSize":1, "deviceName":"<span style="color: #ff0000;">unique-site-identifier</span>", "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:
1 2 3 4 |
: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:
If this post helped you, please leave a comment!
Raspberry Pi internet streaming radio station
My partner has been overseas for a few months and was desperately missing a local radio station. It doesn't have an online stream that she can listen to and so she asked me ... Read more
Read the RFCs
I recently moved a bunch of websites over to a VPS (likely the one you are reading this from). It runs Ubuntu with a LEMP stack. I ran into some problems when ... Read more