Monitoring OpenWrt with collectd, InfluxDB and Grafana

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.

OpenWrt stats in Grafana

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.

4 thoughts on “Monitoring OpenWrt with collectd, InfluxDB and Grafana

  1. Carlos

    Thanks for the great blog posts. I have followed both the “Monitoring host with Prometheus, Influxdb and Grafana” and “Monitoring OpenWrt with collectd, InfluxDB, and Grafana” posts. I was able to get the first one working and added all my hosts and everything seems to be working properly now. However, when I try to add my OpenWRT router, I can’t seem to get the metrics displayed on my Grafana dashboard. I have tried querying the Influxdb side and I can see that the metrics are getting there correctly, however they are not appearing on the grafana dashboard. Do you have any suggestions on how to troubleshoot the grafana dashboard?

  2. Chris Post author

    Hey Carlos, OK so it sounds like your data is getting to Influxdb fine, so maybe this is an issue with Grafana talking to it. Are both services on the same node? What does your datasource look like for Influxdb? Is it pointing to the right IP and the right database?

  3. Jarkko

    Thanks! Great article and got it working. Had to configure influxdb with collectd listener and import types.db file to it. And on Grafana side you have to make sure that data source has right database selected.

    I’m using TurrisOmnia router.

Leave a Reply

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