Monitoring RBPi with Glances & Home Assistant in 2024
If you’re reading this on fediverse and the layout is off, here’s the link to the original blog post with a nice text & pictures layout.
Few years ago (2019?) it was like:
pip install glances
And voila, I could monitor CPU, disk etc. of my Raspberry remotely via web browser (if my memory serves but it probably doesn’t).
After I started tinkering AGAIN with my Raspberry PIs after 4 years, I found out things got … complicated. Or I’m just old.
Instead of ONE step, I had to research quite a bit how to enable Glances again. Now it’s like:
- Create virtual environment in Python just for Glances (venv something something)
- sorry, no command here, my RBPI crashed in between and I don’t know how to find the history of commands.
- probably not needed
- The official Python docs are great: you have to 1. install venv and then 2. activate it. The commands below include <path to venv> because I didn’t know that I don’t need to use the path if I activate this venv.
- Install Glances
<path to venv>/bin/pip3 install glances
- Run Glances in web server mode just ot find out a bunch of stuff is missing (fastapi)
<path to venv>/bin/glances -w
- Spend 1 day figuring out why ‘pip install’ is not installing just to find out I have to use pip3 (thanks forums)
- when I used ‘pip install’, it started installing, but threw a whole bunch of weird errors. I thought something was wrong with my internet connection.
- Install Fastapi (web framework)
<path to venv>/bin/pip3 install fastapi
- Run Glances again to find out more of stuff is missing (uvicorn)
- Install Uvicorn (web server)
<path to venv>/bin/pip3 install uvicorn
- Run Glances again to find out more of stuff is missing (jinja2)
- Install Jinja2 (templating language)
<path to venv>/bin/pip3 install jinja2
But hey, not everything is bleak. I finally learnt what venv is and used it for the first time. It’s just an island with an isolated python environment. Yes, I know, I’m slow.
Glances run at <your host>: 61208 and when I access it via web browser, it looks like this:
The whole reason why I wanted to install Glances is to monitor RBPI from Home Assistant. There is a nice Glances integration that works out of the box:
Glances consume ~40% of poor RBPI Zero W CPU, which is quite a lot.
I wonder if there is a tool to monitor CPU that is not CPU intensive…
Update 1: if I don’t access it via web browser (only via Home Assistant), the CPU usage is 12%. Much better.
Next step >> make glances automatically start after a reboot
Leave a Reply