Recently I've been playing around with the open source versions of InfluxDB and Grafana as a solution to collecting data from my Smart Home and Network devices, and putting that information on snazzy looking dashboards and graphs.
Now there are lots of solutions to collecting and graphing data on Vera, such as Datamine, Datayours and the AltUI plugins. I went down the Influx/Grafana path for a couple of reasons:
- I didn't want to put a heavy load on my Vera automation controller - it has important things to do like turn on my bathroom fan thank you very much.
- I wanted an open platform that could collect data from all of my home devices (Windows, Linux, Unifi, QNAP) and the Cloud services I use without me having to write a lot of integrations/code.
- I wanted to graph/dashboard my Vera home automation data (Power, Temperature, Door Status etc.) in the same place as my IT/Network data.
Installing Influx and Grafana is beyond the scope of this blog, but there are plenty of resources on the web to get it up and running. You could run it on a Raspberry Pi, a PC or VM running Linux, or in my case as Docker Containers on my QNAP NAS.
I started this project with looking at a way to collect system performance data from Vera. In particular uptime, memory, cpu and disk usage - the basics to make sure that Vera is operating normally. One of the protocols that Influx supports is collectd which is a part of many Linux distributions, including the OpenWRT one which Vera uses under the covers.
The catch is that Vera doesn't include collectd on Vera or in the MiOS repository that it uses. So that means we're going to have to roll up our sleeves and break out a command line interface.
First up, a warning. Playing around with your Vera's underlying operating system is potentially dangerous and definitely frowned upon by Vera/MiOS support. This is an "at your own risk" and "abandon all hope ye who enter here" type deal if it goes wrong.
To proceed with voiding your warranty, you will need:
- Vera root credentials (username/password)
- Putty (or other SSH terminal)
- WinSCP (optional, but so much easier than using vi in Putty).
- collectd packages suitable for the architecture of your Vera (explained later).
- InfluxDB instance with collectd protocol enabled on port 25826.
- An Influx DB collectd database with appropriate retention policy.
- Grafana instance with InfluxDB datasource configured.
- Enough free Vera storage space to allow for the install of collectd.
- Cojones of Steel
If you've passed your own gut check at this point and believe you know what you're doing, let's begin.
Step 1 - Add OpenWRT repository
At the time of writing, my VeraPlus was running the BARRIER BREAKER v14.07 release of OpenWRT using architecture ramips_24kec.
You can verify using these commands:
# cat /etc/openwrt_version
# opkg info opkg | grep Architecture
This is an older release of OpenWRT (so unfortunately we get a pre-5.0 version of collectd) but the packages are still available online.
Next use WinSCP to edit the /etc/opkg.conf file and add the following line to the end:
src/gz barrier_breaker http://archive.openwrt.org/barrier_breaker/14.07/ramips/mt7620n/packages/packages
Important Note: when all this is done, I recommend commenting out/removing this repository to prevent non-MiOS validated packages being updated accidentally.
Step 2 - Install collectd
At this point we're installing the main collectd package and some of the monitoring modules. We'll do the ones that are configured by default, they're probably more than enough for keeping an eye on Vera. Run the following commands:
# opkg update
# opkg install collectd
# opkg install collectd-mod-cpu
# opkg install collectd-mod-df
# opkg install collectd-mod-disk
# opkg install collectd-mod-interface
# opkg install collectd-mod-load
# opkg install collectd-mod-logfile
# opkg install collectd-mod-memory
# opkg install collectd-mod-network
At this point, assuming you didn't get any error messages I'd recommend removing the repository from opkg.conf and proceeding to the next step.
Step 3 - Configure collectd
You'll find the configuration settings in /etc/collectd.conf - there are two settings you should change for the purposes of getting your data to InfluxDB and being gentle on Vera.
The first is the data polling period in the general section of the config file. The default is 10 seconds, dial this in to the period that suits you. I chose 60 seconds.
Next is the network plugin. This needs to be configured to send data to a collectd server (which is InfluxDB in our case). Make sure at least these 3 lines are uncommented, I left everything else as-is.
Server "192.168.0.29" "25826"
Step 4 - Start collectd and enable start on boot
Back to putty and run the following commands:
# /etc/init.d/collectd enable
# /etc/init.d/collectd start
If you now check in Influx (using Grafana, CLI or InfluxDB Studio) you should see Vera's vital statistics appearing in the database.
If you ever need to stop collectd running or prevent it from starting automatically, you can replace 'enable' and 'start' in the commands above with 'disable' and 'stop'.
Step 5 - Visualise
Over in Grafana, you can create some charts or download some pre-existing dashboards for collectd from grafana.com to save yourself some time.
Just a reminder on what was mentioned earlier - this is a pre-5.0 version of collectd, and some of the dashboards expect certain data which isn't part of 4.7. It just means you'll have to rework some chart queries and maybe use some math functions. If anyone can tell me how to get a newer version of collectd running on Vera, please let me know.
Anyway, here's a quick snapshot of what you can expect when you've got it all working:
I'll cover more on Grafana and Influx in other blogs, including a Plugin I created to take your Vera sensor data and automatically pump it into Influx.
Share this post
- Tags: Projects