HA 0.116 / Supervisor 247 - Core and Supervisor & Addon Stats

ok thanks.
as for the Portainer if you have time… I did find the hidden containers, but can only Remove them :wink:

and the Add-ons are listed as Images:

They are not the containers. They are the instructions to hide the containers.

Access to these containers can be gained by going into Portainer → Settings → Hidden containers. Then delete the listed hidden labels (io.hass.type labels). Only do this if you know what you’re doing!

Tom,

Why are you dividing by 4? That sensor tells you how much CPU is used by supervisor. Why does the number of cores matter?

Also I have similar for all addons etc… check my system monitor package in my repo.

Because the report returns the sum of all cores.

Ok but if supervisor is telling you CPU percentage then can that not be spread over 4 cores?

Yes it can, which is why you have to divide by 4 to get a real percentage. Consider this, if the process is using 100% of all 4 cores it is reported as 400%, which is kinda daft. Hence to get a real pet-cent (per 100) you divide by the number of cores. Thus it is now reported as 100% use of the total available cpu resources.

If the process was using 100% of one of four cores, this would now be reported as 25% instead of 100%.

Reporting 100% if not dividing by 4 may mislead you into thinking all resources are used unless you remember the total available is (the mathematically improper) 400%.

1 Like

Ok. I would have assumed and expected that it was taking that into account. I will have to investigate this on my system.

It’s definitely using the sum of the cores on my system, I used to see usage in excess of 200%. Also see: https://discord.com/channels/330944238910963714/332167321311510530/766620091302412300

Also I may have a way to implement these sensors over https locally using the rest sensor (less overhead than the command line sensor). Testing today…

1 Like

Ok so you can use an https local api endpoint if you set verify_ssl to false an use this endpoint shown below.

Core and Supervisor (set the template divisor to the number of threads your CPU supports):

- platform: rest
  resource: https://homeassistant:8123/api/hassio/core/stats
  name: Core CPU
  unit_of_measurement: '%'
  value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
  scan_interval: 60
  verify_ssl: false
  headers:
    Authorization: !secret ha_api_token
    Content-Type: application/json
  json_attributes_path: "$.data"
  json_attributes:
    - memory_percent

- platform: rest
  resource: https://homeassistant:8123/api/hassio/supervisor/stats
  name: Supervisor CPU
  unit_of_measurement: '%'
  value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
  scan_interval: 60
  verify_ssl: false
  headers:
    Authorization: !secret ha_api_token
    Content-Type: application/json
  json_attributes_path: "$.data"
  json_attributes:
    - memory_percent

- platform: template
  sensors:
    core_memory:
      friendly_name: "Core RAM"
      value_template: "{{ state_attr('sensor.core_cpu', 'memory_percent') }}"
      unit_of_measurement: '%'
    supervisor_memory:
      friendly_name: "Supervisor RAM"
      value_template: "{{ state_attr('sensor.supervisor_cpu', 'memory_percent') }}"
      unit_of_measurement: '%'

Addon

- platform: rest
  resource:  https://homeassistant:8123/api/hassio/addons/core_duckdns/stats
  name: DuckDNS CPU
  unit_of_measurement: '%'
  value_template: '{{ (value_json.data.cpu_percent|float/4)|round(2) }}'
  scan_interval: 60
  verify_ssl: false
  headers:
    Authorization: !secret ha_api_token
    Content-Type: application/json
  json_attributes_path: "$.data"
  json_attributes:
    - memory_percent

- platform: template
  sensors:
    duckdns_memory:
      friendly_name: "DuckDNS RAM"
      value_template: "{{ state_attr('sensor.duckdns_cpu', 'memory_percent') }}"
      unit_of_measurement: '%'

Secret (Long Lived Access Token, set in your profile):

ha_api_token: "Bearer eyJ0eXA..."

would you know of a way to get this working over the local resource, (vs the now configured duckdns resource) in

  - platform: rest
    name: Hassio Rpi4 config
    resource: !secret resource_hassio_rpi4_config
    value_template: > #components|list|count}}
      {{value_json.version}}
    json_attributes:
      - components
      - unit_system
      - config_dir
    headers:
      Content-Type: application/json
      Authorization: !secret api_bearer_token
      User-Agent: Home Assistant REST sensor
    scan_interval: 3600

and resource:

https://redacted.duckdns.org:1234/api/config

?
tried a few endpoints but with no real luck so far…or should I simply use that

https://homeassistant:8123/api/config

cant be that simple??

update
no it can’t…

anyone got the Portainer add-on working?

this is the info

- description: Manage your Docker environment with ease
  icon: true
  installed: 1.2.2
  logo: true
  name: Portainer
  repository: a0d7b954
  slug: a0d7b954_portainer
  state: stopped
  version: 1.2.2

so I am using

  - platform: command_line
    name: Stats Portainer
    command: >
      curl -sSL -H "Authorization: Bearer $SUPERVISOR_TOKEN" http://supervisor/addons/a0d7b954_portainer/stats
    unit_of_measurement: '%'
    value_template: >
      {{value_json.data.cpu_percent}}
    scan_interval: 60
    json_attributes:
      - data

like on all other add-ons, but this one remains Unknown. Even after having started the add-on.

btw Ive tried to go ups 1 branch in the resource too and use

 http://supervisor/addons/a0d7b954_portainer

and adjusted the value_template too, but still nothing happening.

it can be if

right! thanks, can confirm this works indeed:

  - platform: rest
    name: Hassio Rpi4 config local
    resource: https://homeassistant:8123/api/config
    value_template: > #components|list|count}}
      {{value_json.version}}
    verify_ssl: false
    json_attributes:
      - components
      - unit_system
      - config_dir
    headers:
      Content-Type: application/json
      Authorization: !secret api_bearer_token
    scan_interval: 3600

very nice, hope this makes it easier at startup.

1 Like

Good idea. Wish there was a component that automatically shows together the CPU and RAM usage of all components (Supervisor, Core, Addons, …)

BTW how do you get the Network Interface throughput?

Nevermind, found that system monitor can create sensors for network interfaces

Tom
What are the units for network_tx and _rx in the cli stats command?
On a side note, I’m restoring a 11GB backup on a NAS to a new bigger SSD. I started with a fresh install (Generic X86-64) and selected Restore at the start. It’s been going for over 24 hours! Is there any way how far I can tell it’s got?

No idea but it looks like “bits”.

All my network stats come from either the snmp or system monitor integrations.

Most of the information in this topic is outdated. It can now be obtained through the Home Assistant Supervisor integration.

Maybe this is the right thread because i am searching for a sensor or template sensor to count addons and also community addons.

Can you help me please?

do you mean counting Integrations (rather than Add-ons as they are different)…if you do try Spook (a custom integration)…there’s a thread here on the Forum or go straight here https://spook.boo/

Yes, I mean Integrations.
Thank you, I´ll habe a look at it.

1 Like

that’s the forum thread