I have been chasing down an intermittent (but prolonged - requiring a restart to stop) high core CPU use for weeks. Profiler and py-spy have failed to reveal the culprit. So my next option was going to be disabling addons one by one.
I’ll implement these sensors instead and see if that helps track the issue down. Thank you.
And as you can see from the graph it has been growing steadily up.
However, monitoring the same statistic in the supervisor it never gets above 7%:
EDIT: I just saw the supervisor core cpu monitor hit 98%, very briefly - about the same time as the api sensor updated. Is the cpu API call causing the cpu use to skyrocket?
Why does restarting home assistant stop this happening?
EDIT2: in case this is caused by multiple api calls happening at once I have updated my rest sensors to use different prime number scan intervals, from 23 to 71 seconds.
If you use internal access to the API this considerably reduces the overhead. As I use duckDNS and its security certs I have to use https and so accessing
resource: http://supervisor/core/stats
will not work for me. If you can access home assistant locally via http use that resource. However if you use TLS certs directly in home assistant you can can get around this by using a command line sensor instead:
as I am on Homeassistant OS and always use the !secret for the bearer token, please le me ask where your token is stored when you use "Authorization: Bearer $SUPERVISOR_TOKEN" ?
$SUPERVISOR_TOKEN is like a system variable. No need to define a token! Just use that template verbatim. I don’t know if it can be used in the rest Authorisation option though. I suspect not.
None od my add-ons seem to be there… I noticed something this morning already when installing the Portainer, and all it could find was the hassio_observer
The home assistant containers are hidden by default. Read the portainer addon docs, it tells you how to un-hide them. I’d tell you but it’s ages since I did it and I’ve forgotten.
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!
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%.