How to access core and supervisor CPU + MEM usage (HA OS)

I want to have those 4 numbers as sensors:

  • Those are from the former, now “hidden system management” page /hassio/system.
  • Less important: number 5, which is available e. g. via System Monitor - Home Assistant.
    Interesting: the disk usage of this sensor.disk_use_percent (from system monitor) with 67.9 % differs from the one shown as 5 in the screen.

So: how to get CPU + MEM usage of HA Core and HA Supervisor?

Glances - Home Assistant unfortunately does not provide that information (only total cpu/mem of all docker containers) and - obviously - needs to run the Glances addon. And there’s no Portainer integration unfortunately, that would be one way in theory.

Preferred looking at a solution

  1. as “stock” / “out of the box” (low effort, no additional integrations/addons needed) as possible
  2. avoiding the use of GitHub - ualex73/monitor_docker: Monitor Docker containers from Home Assistant or other custom integrations from HACS
  3. avoiding command_line sensors (except if it’s the only option, well…)

Ideas / working proofs welcome :slight_smile:

Core stats and supervisor stats.

Use a rest or restful sensor.

I haven’t tried.

Nice, thanks :+1: Never used one before. If someone has a working yaml snippet containing the authentication part for the supervisor… thanks for sharing.

I made a couple posts about them recently.

Post two

Although you might actually want a restful sensor if you want more than one thing from each endpoint

1 Like

Still no progress on this.

I found the information needed to be in

  • Core CPU: /core/stats as data.cpu_percent
  • Core MEM: /core/stats as data.memory_percent
  • Supervisor CPU: /supervisor/stats as data.cpu_percent
  • Supervisor MEM: /supervisor/stats as data.memory_percent

I’d prefer to use a RestFUL sensor, but even more complicated than a REST sensor.

For the REST sensor:
Are they “hot reloadable” from /developer-tools/yaml? Or is a HA Core restart required?

I really wish this would just be in the Supervisor integration out of the box as it is for other addons too.

I went with a old-school command_line sensor (I basically try to avoid using them meanwhile but the struggle with the REST or RESTful sensors is even worse).

Unfortunately, after initial load of the CL sensors, the value never gets updated, so the scan_interval is not respected. E. g.:

  - platform: command_line
    name: Home Assistant Core CPU percent
    unique_id: vs-code-generated
    scan_interval: 30
    command_timeout: 60
    command: 'curl http://supervisor/core/stats -H "Authorization: Bearer $(printenv SUPERVISOR_TOKEN)" | jq ''{"cpu_percent"}'''
    value_template: "{{ value_json.cpu_percent }}"
    unit_of_measurement: "%"

The changes visuable are from reloading CL sensors:

Any idea on this e. g. @ master of CL sensors @CentralCommand ?

Meanwhile TBH I am so bugged :frowning_face: that I’m just ten minutes away of writing a feature request (knowing it will either not get realized or only in many months) for the Supervisor integration. The data is already there, why not exposing it for Core and Supervisor as done for all the other addons?


Is it possible that scan_interval for CL sensors has been disabled/ignored a long time ago already? Because:

  • I probably have few other CL sensors which never update (only on manual reload and HA start)
  • Using the homeassistant.update_entity service triggers the CL sensor update just fine.