Monitoring OpenWrt with collectd, InfluxDB and Grafana

In my previous blog post I showed how to set up InfluxDB and Grafana (and Prometheus), please see that post on how to configure them. 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.

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

  1. 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. 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. 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.

  4. Hello, interesting article. I am something new in the subject but I have the case that I have three router with openwrt in different houses and I want to monitor from a single point the data collected by collectd in these three houses, in that case how would the configuration of the influex server and others be?

  5. Ahh well I haven’t done that, but I guess you need a way to send that data to the central point, probably either be over a VPN or the Internet through your router. You would then set that public or VPN IP in the Output plugin under server interfaces, as per the blog post.

  6. Hello,
    Why my Wireless Clients and my OPVN stays empty? All other Diagrams fill up with Data, only the two still remain empty?

    Can u help with it?

  7. Hi,

    Thx a lot !!!!!
    Same issue here: no WiFi client count, I haven’t any stations filter in my iwinfo_value query.

    Any idea ? Best regards.

  8. Hi,

    Thx a lot for you article ! I can monitor all my OpenWRT on my home !

    Juste an issue, I have no data for “Number of wireless client”. After analyse of the query, I haven’t any data for type “station”. Any idea ?

    Best regards.

  9. Yep, sorry. It’s covered in the linked blog post about setting those platforms up. Maybe I should add it to this one, too. Thanks.

  10. Thanks Chris for the post and llaumgui with the last types.db tip.
    Just copying this file to influxdb dir makes the number of wireless clients work like a charm!
    Grafana dashboard for OpenWRT fully working now.

  11. Hey Chris, this seems like a great article, Im following the steps but it looks like my influxdb is not listening to collectd.
    I have tried to check everything but I cant get it working.

    Im running a collectd server on a raspberry pi, getting collectd info from my router openwrt, it is working, I can see the connection and the data that collectd is saving, but im stuck there, influxdb is not getting anyinfo, grafana is ready reading influxdb but is the DB that is empty

    Please can you give me a hint what else to try?

  12. I did, but I didnt use prometheus couse I understand its for local monitoring (it will be my raspi) and in fact im mainly looking for monitoring some routers only (for now). It can be done in this way or i must install Prometheus mandatory?

    Thanks pr replying!

  13. If someone is having troubles showing the data (If no data is shown in grafana), check your influxdb version.

    Version 1.6.4 dont show results, update to 1.8+

  14. Hi

    Are you able to get some stats per hots (=all devices connected to the router by name or IP), like traffic per host in real time?

  15. Hi Chris, given you are rebuilding your monitor machine, have you looked at how to use this on InfluxDB2? I have a server setup already, and it seems you have to use telegraph to convert the collectd output but information is scarce! Thanks.

  16. If your OpenWrt router doesn’t have any Wi-Fi devices the host list is incomplete, this can be fixed by changing the query for the host list to e.g. SHOW TAG VALUES FROM “interface_rx” WITH KEY=host

Leave a Reply

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