In my previous blog post I showed how to set up InfluxDB and Grafana (and Prometheus). This is how I configured my OpenWrt devices to provide monitoring and graphing of my network.
OpenWrt includes support for collectd (and even graphing inside Luci web interface) so we can leverage this and send our data across the network to the monitoring host.
Install and configure packages on OpenWrt
Log into your OpenWrt devices and install the required packages.
opkg update opkg install luci-app-statistics collectd collectd-mod-cpu \ collectd-mod-interface collectd-mod-iwinfo \ collectd-mod-load collectd-mod-memory collectd-mod-network collectd-mod-uptime /etc/init.d/luci_statistics enable /etc/init.d/collectd enable
Next, log into your device’s OpenWrt web interface and you should see a new Statistics menu at the top. Hover over this and click on Setup so that we can configure collectd.
Add the Hostname field and enter in the device’s hostname (or some name you want).
Click on General plugins and make sure that Processor, System Load, Memory and Uptime are all enabled. Hit Save & Apply.
Under Network plugins, ensure Interfaces is enabled and select the interfaces you want to monitor (lan, wan, wifi, etc).
Still under Network plugins, also ensure Wireless is enabled but don’t select any interfaces (it will work it out). Hit Save & Apply (I don’t bother with the Ping plugin).
Click on Output plugins and ensure Network is enabled so that we can stream metrics to InfluxDB. All you need to do is add an entry under server interfaces that points to the IP address of your monitor server (which is running InfluxDB with the collectd listener enabled). Hit Save & Apply.
Finally, you can leave RRDTool plugin as it is, or disable it if you want to (it will stop showing graphs in Luci if you do, but we’re using Grafana anyway and you’ll have less load on your router). If you do enable, it make sure it is writing data to tmpfs to avoid wearing our your flash (this is the default configuration).
That’s your OpenWrt configuration done!
Loading a dashboard in Grafana
Still in your web browser, log into Grafana on your monitor node (port 3000 by default).
Import a new dashboard.
We will use an existing dashboard by contributor vooon341, so simply type in the number 3484 and hit Load.
This will download the dashboard from Grafana and prompt for settings. Enter whatever Name you like, select InfluxDB as your data source (configured in the previous blog post), then hit Import.
Grafana will now go and query InfluxDB and present your dashboard with all of your OpenWrt devices.
OpenWrt also supports a LUA Prometheus node exporter, so if you wanted to add those as well, you could. However, I think collectd does a reasonable job.