grafana – Dirty Optics https://dirtyoptics.com Jack of all trades, Master of none Sun, 11 Oct 2020 14:31:05 +0000 en-US hourly 1 How to Monitor a Raspberry Pi Remotely https://dirtyoptics.com/how-to-monitor-a-raspberry-pi-remotely/ https://dirtyoptics.com/how-to-monitor-a-raspberry-pi-remotely/#respond Sun, 11 Oct 2020 13:51:18 +0000 https://dirtyoptics.com/?p=54921 I’m working on a project that houses a bunch of Raspberry Pi computers in multiple remote locations. I wanted to be able to monitor the “Health” of the hardware in these remote locations. The metrics I was hoping to capture are Up-time, CPU temps, CPU usage, Memory and disk usage, etc.. as you may have noticed, I also have a love/hate relationship with Grafana, which made it the only choice for displaying these metrics in a user-friendly way.

Prerequisites:

1 x VM running Ubuntu 20.04 – I tested using a Cloud Compute server on VULTR, but you could use any VM that is on the same network as the RPi.

1 x RPi – As long as the RPi is on the same network it will be good to go. I tested over a VPN and it worked also.

Software Stack:

Influxdb – As usual the time series database.

Grafana – My favorite program for displaying this kind of data.

Telegraf – A plugin server agent for collecting and passing hardware metrics such as CPU, Temps, RAM, Storage, etc…

Install InfluxDb on VM/Host

Install Grafana on VM/Host

PLEASE READ: Now that our host/server has Grafana and InfluxDb Installed. We need to install Telegraf on the RPi that we wish to fetch metrics from. Don’t worry, we will come back and configure Grafana/InfluxDb Shortly.

Install Telegraf on Raspberry Pi (RPi)

Configuration – Telegraf on RPi

Telegraf.conf

PLEASE READ: Now that we are done configuring the Raspberry Pi, it’s back to the VM/Host to configure influx and grafana.

Configuration – InfluxDB on VM/Host

Configuration – Grafana

Navigate to your Grafana Install: http://<server-ip-address>:3000

Login: default login is admin:admin

Please change the username and password straight away.

The first step is to add the Influxdb data source:

Grafana Datasource

The second step is to import the Dashboard – We used this dashboard from the Grafana Library:

https://grafana.com/grafana/dashboards/10578/reviews Props to Jorge

To import the dashboard, navigate to DASHBOARD > MANAGE > IMPORT

Insert 10578 into the field and click ‘Load’

Grafana Import Dashboard

 

 

 

 

 

Make sure you then select the datasource to associate with the dashboard.

Grafana Import Dashboard

 

 

 

 

 

You should now be greeted with a Dashboard that is connected to the RPi.

Dashboard Complete

 

The rest is now up to you! Add multiple RPi’s. You can switch between them at the top of the Dashboard.

A big thanks to Dorian Machado and his article. Also Jorge de la Cruz and his Dashboard! These guys did the real heavy lifting.

]]>
https://dirtyoptics.com/how-to-monitor-a-raspberry-pi-remotely/feed/ 0
Batrium integration with Home Assistant https://dirtyoptics.com/batrium-integration-with-home-assistant/ https://dirtyoptics.com/batrium-integration-with-home-assistant/#comments Sun, 06 Sep 2020 11:07:39 +0000 https://dirtyoptics.com/?p=54815 The ultimate goal is to be able to monitor my power-wall in the Home Assistant (HA) dashboard. In my case, HA runs on a 10″ android tablet out in the Kitchen. Firstly, I need to throw some recognition to a couple of people. The first being @Wolf. Absolute legend helped me out with some Node-red issues, and basically, without him, the 2-3 days development time would have turned into weeks. A Full list of recognition is at the bottom of the past! Enjoy!

Oh and yes I could have done this whole install on Docker/Portainer and I most likely will go down that route, but for now, this is the down-and-dirty version line by line.

Prerequisites

  • Ubuntu 20.04 LTS Server Installed on a VM or PC.
  • A Batrium Watchmon on the same network as your VM/PC.
  • Node-Red Flow (JSON file) Download Here.
  • Grafana Dashboard (JSON File) Download Here.

Step 1 – Update/Upgrade

Step 2 – Install Grafana

Step 3 – Install InfluxDB and Chronograf

INFLUXDB Install

CHRONOGRAF Install (Not Essential, but good for fault finding.)

CREATE INFLUX DATABASE (For use with Grafana)

Step 4 – Install Node-Red

NODE-RED BOOT ON STARTUP

Step 5 – Configure Node-Red

Once Node-Red is installed we need a few additional packages installed to allow Node-Red to interpret the UDP data coming from the Batrium Watchmon. The 3 packages are:

  • Binary-Parser (Install via Linux CLI)
  • node-red-contrib-influxdb (Installed in Node-Red GUI)
  • node-red-dashboard (Installed in Node-Red GUI)

The latter two items can be installed via the “Manage Palette” function in the Node-Red Settings. The Binary Parser function needs to be installed via the CLI.

Now you need to import the Flow into Node-Red. You can download the flow here. Of note here is that this flow is set up to listen for the Batrium UDP data on port 18542. We opened up this UDP port during the Node-Red install. This flow is also set up for a string of 14 longmons. If you have more as I do, then you will need to edit some of the nodes to reflect this.

 

node-red influx configWe now need to configure a couple of nodes in Node-Red. The main configuration is pointing node-red influx flow to the database we created after we installed influxDB. In this tutorial we created a database called “batrium” and we know that the port for influx is 8086.

 

deploy and debugNow we need to Deploy the Node-Red flow and check the debug tab for any errors. If you see some “TypeErrors” then it is usually because the Binary-Parser was not installed correctly. Also, you can toggle the green msg.payload debug filters on and off to see the data being received in the debug window.

Step 6 – Configure Grafana

We now need to set up Grafana. In a nutshell, we need to do two things. First, add the influxdb data source. Secondly, import the Dashboard that Mr @Wolf has been nice enough to allow us to share. You can find a copy of the JSON file here.

Setup Data Source:

Import Dashboard:

grafana dashboardDepending on your battery type, amount of longmons, etc. you will need to play around with the visualization. If you have come this far I’ll let you figure out your ideal settings.

Step 7 – Configure Home Assistant

We are going to add the Grafana dashboard into Home Assistant using an embed from Grafana. Log back into your Grafana instance and locate the share button on your dashboard.

Find the Grafana Dashboard share/embed tab:

Use the link created in Grafana to create a new entity in HA. I also append the following to my link to ensure it opens in ‘fullscreen’ and ‘kiosk’ mode in HA. &kiosk&fullscreen 

If your dashboard does not show up in HA, read on below to fix.

Dashboard embed fix – From what I have found online, most users report that just enabling the ‘allow_embedding = true’ function sorted the issue. I had to allow anonymous logins also. But that is probably because I have not set up a user in Grafana for Home Assistant. Use the anonymous logins at your own risk.

Well it’s been emotional, thanks for sticking with me. If you find something wrong here let me know and I’ll fix it up asap. I hope it helps and again, thanks to the contributors.

Batrium in Home Assistant

Recognition

https://github.com/Bloats/Powerwall-stuff – Bloats for the original Flow

https://secondlifestorage.com/showthread.php?tid=8645&pid=59143 – Of course, the Second Life Storage Forum!

https://discourse.nodered.org/t/flow-to-decode-binary-data-and-a-walk-through-on-how-to-install-the-npm-module/5174 – Binary-Parser info

https://github.com/daromer2 – For his initial work with the UDP listener!

]]>
https://dirtyoptics.com/batrium-integration-with-home-assistant/feed/ 10