Remote Monitoring with Glances

![](upload://mjRJNl6Hew6amvgoQdlt9h4dekq.png) Inspired by a feature requests I started looking into the available options to do monitoring of remote hosts. The feature request is about displaying system information in a similar way than the systemmonitor sensor does it for the local system. After a while I started to think that it would be a nice addition for a small home network where no full-blown system monitoring setup is present.

The basic problem is to get the data from the remote host. Starting with psutil that is used by the systemmonitor sensor, a possible solution is only a click away and named Glances. Glances has a nice curses-based interface and a RESTful API.

The Glances sensor sensor uses that API to get all needed data.

In this post a default Fedora 22 Workstation installation is used on the host that should be monitored. In fact, it doesn’t matter if the system is the local one or a remote one as long as Glances is available. With some adjustments it should work on your own systems too. The difference will be the package and the firewall management tools.

First some extra packages are needed beside Glances, especially the bottle webserver. I guess that Glances is available for your distribution as well. Otherwise follow those instructions.

$ sudo dnf -y install glances python-bottle

On Fedora the Firewall settings are strict. Let’s open port 61208 to allow other hosts to connect to that port. This is not needed if you just want to observe your local machine.

$ sudo firewall-cmd --permanent --add-port=61208/tcp
$ sudo firewall-cmd --reload

Launch glances and keep an eye on the output.

$ glances -w
Glances web server started on

Now browse to http://IP_ADRRESS:61208/. You should see the webified view of Glances.

![](upload://65BNy0d4xkh5XZ7Wxmf8iZoNTf1.png) Glances web interface

Another check is to access the API located at http://IP_ADRRESS:61208/api/2/mem/used and to confirm that a detail about your memory usage is provided as a JSON response. If so, you are good to proceed.

$ curl -X GET http://IP_ADDRESS:61208/api/2/mem/used
{"used": 203943936}

Add the glances sensor entry to your configuration.yaml file and restart Home Assistant then.

# Example configuration.yaml entry
  - platform: glances
    name: NAS
    host: IP_ADDRESS
      - 'disk_use_percent'
      - 'disk_use'
      - 'disk_free'

If there are no error in the log file then you should see your new sensors.

![](upload://eYvZTQLCZ5rKiL1h9XbIiokJpCi.png) The Glances sensors

Glances has a couple of optional dependencies which are extenting the range of provided information. This means that it would be possible to get details about the RAID system, HDD temperature, IP addresses, sensors, etc., please create a Pull request with your additions or a Feature request if you want see more details in your Home Assistant frontend.

This is a companion discussion topic for the original entry at

Is there a special trick to use this with HA in docker?
I can open the dashboard from my computer, but HA throws errors:

Platform glances not ready yet. Retrying in 30 seconds.
Unable to fetch data from Glances
Can not load data from Glances API

I can curl i.e. CPU Load from directly from my Pi but not from within the HA container

1 Like

The trick is…
use Glances v3.1.0 with psutil v5.6.3.

I did the installtion with

curl -L | /bin/bash

Running glances as a container as described here returns a known error:

standard_init_linux.go:207: exec user process caused "exec format error"

In Fedora 29 at least, you need to install python3-bottle instead of python-bottle and the api url is

curl -X GET http://IP_ADDRESS:61208/api/3/mem/used

instead of

curl -X GET http://IP_ADDRESS:61208/api/2/mem/used

I installed Glances on a Pi02 in docker on my network. I wanted to add Glances to HA on a separet Pi. But it cannot connect for some reason. IP is ok. “Unknown error occurred” (And it worked earlier…)Version:3.17.1. When I open it from the pi02 it shows all the data.