MikroTik Script: Push Router Stats to dweet.io

MikroTik Script: Push Router Stats to dweet.io

In this tutorial, I will show you how to create a RouterOS script to push Router statistics up to dweet.io and then use that data to create a nice monitoring dashboard with slick gauges and graphs over at freeboard.io.

Disclaimer: dweet.io data feeds are public so consider this before pushing any sensitive data up to dweet.io. They do have a commercial accounts in which you can lock (make private) data feeds. freeboard.io dashboards are public by default but can be make private. Also, this script is provided as-is, use at your own risk.

MikroTik Script to push router stats to dweet.io

Install the script

  1. In Winbox, click System | Scripts
  2. From the Script List, click the Add (+) toolbar button
  3. Paste in the above script and name it “dweet-stats”mikrotik-script-push-dweet-stats

Before we create the schedule, you will want to adjust the Setup section of the scripts and make sure it executes without error.  My WAN interface name is ether1 but some RouterOS configs name it ether1-gateway or you may be using a different interface for your WAN port.  The above script also assumes that your wireless interface is named wlan1 and that you have a guest wireless interface wlan2. If you run into problems or have no wireless interfaces on your router just comment out those lines and adjust the finalurl variable to exclude that data.

Test Execute the script

  1. In WinBox, click New Terminal
  2. Paste in /system script run dweet-stats and press [enter]

The script should execute without syntax errors and give you output similar to this…

Schedule the script to run every X minutes or seconds

  1. In Winbox, click System | Scheduler
  2. From the Script List, click the Add (+) toolbar button
  3. Name the schedule “run-dweet-stats” and set the Interval: ie. 00:01:00 = Every 1 minute
  4. Paste /system script run dweet-stats into the On Event: boxmikrotik-schedule-dweet-script

View your router stats on dweet.io

Your router’s data will land at http://dweet.io/follow/mikrotik-stats-<serial-number>

Here is what you can expect to see http://dweet.io/follow/mikrotik-stats-3E2E02190C64

mikrotik-iot-data-stream-dweet
Click to Enlarge

You can also see the raw data that is being submitted by clicking on the Raw tab.

mikrotik-dweet.io-raw-data

A Real Time Dashboard for your Router Stats

Next, we can work with the dweet data to build a dashboard with freeboard.io.  Checkout the one I created here https://freeboard.io/board/5a20d586511f114a61002d82.

mikrotik-router-freeboard-dashboard
Click to Enlarge

To create your own dashboard you can click the big orange button on your dweet.io thing page or you can clone my dashboard and change the datasource to your dweet.io thing name.

create-clone-freeboard-io

Future Enhancements

I plan on adding WAN interface TX/RX utilization stats to the script.  What else do you think would be useful? comment below

Reference

Comments are closed.