Monitoring RBPi with Glances & Home Assistant in 2024

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:

  1. 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.
  2. Install Glances
    • <path to venv>/bin/pip3 install glances
  3. Run Glances in web server mode just ot find out a bunch of stuff is missing (fastapi)
    • <path to venv>/bin/glances -w
  4. 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.
  5. Install Fastapi (web framework)
    • <path to venv>/bin/pip3 install fastapi
  6. Run Glances again to find out more of stuff is missing (uvicorn)
  7. Install Uvicorn (web server)
    • <path to venv>/bin/pip3 install uvicorn
  8. Run Glances again to find out more of stuff is missing (jinja2)
  9. 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:

screenshot of Glances, web page that shows monitoring of RBPI's cpu, disk, etc.

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:

screenshot of Home Assistant with Glances integration, it shows monitoring of RBPI's cpu, disk, etc.

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

Tags:

Comments

2 responses to “Monitoring RBPi with Glances & Home Assistant in 2024”

  1. Beko Pharm Avatar

    @tomi guess I'll go with ssh+btop(++) any day.

    Also yes, Python is becoming more and more of a pain in the neck for people that don't use it every day trying to solve the same old problems. venv? The cool kids use Poetry or Conda to run their little snippets nowadays and I guess we can be happy that they don't ask you to just run a Dockerfile 😩

    1. Tomi the Slav and 1024 others Avatar

      @bekopharm @tomi Poetry, Conda? Ok, officially I'm old.
      Thanks for btop++, does it integrates to HA? A quick search returned no results…

Leave a Reply

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