How to install Py spy on a HA OS instance, please instruct

yes, but I am not sure why you say this now. Did I make a mistake above in the listing of actions required? I am using an external terminal to do all this, so no issue there.
sorry if I misunderstand what you’re saying Mike.

Well I noticed you linked it around discord and places. Which makes sense, it is a pretty complete guide. I was thinking if you are going to keep linking it you might want to update it to use the Community SSH addon approach instead of recommending setting up host SSH. Mostly since its significantly easier for others to do that. No formatting a USB drive and restarting required, just a few clicks from the UI.

thanks, you’re right, and consider that done, I added your suggestions.
See: How to install Py spy on a HA OS instance, please instruct - #44 by Mariusthvdb

@bdraco any chance you can look at my svg files and help me narrow down the issue? My pi4 usually has very minor load and sometimes could be after a day could be after a few hours it really spikes and stays high the only fix is to restart the HA container. There is nothing in the logs at that time either, so I am pretty stumped. I included py-spy svg snapshots for when I have good usage and bad. I suspected it was MQTT but reloading it didn’t solve the issue.
Thank you soo much!
bad cpu usage svg snapshot: https://secure.fabriceleven.com/g23hio+
good cpu usage svg snapshot: https://secure.fabriceleven.com/V8AQnu+

Nothing stands out as an obvious issue.

Can you get an strace -p <pid> -f -s4096 -o /config/spin.log ?

You may have to run apk install strace

Don’t post it though as it could happen to read a file with sensitive data when its logging. PM me and I’ll send you my dropbox or google address so you can share it securely.

Thank you! :heart: No problem. Already reloaded HA though… now we wait :slight_smile:
btw to install strace its
apk add strace

Mem: 3657596K used, 225460K free, 10448K shrd, 289212K buff, 1609196K cached
CPU:  35% usr  21% sys   0% nic  35% idle   0% io   0% irq   7% sirq
Load average: 4.47 4.44 4.60 5/1134 2261
  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
   64    61 root     S     903m  24%   0   2% python3 -m homeassistant --config /config
  127    64 root     S     699m  18%   1   0% /config/rtsp2webrtc_v5_aarch64 {"server":{"http_port":"127.0.0.1:8083","ice_servers":["stun:stun.l.google.com:19302"]},"streams":{}}
  143    64 root     S     697m  18%   2   0% /config/rtsp2webrtc_v5_aarch64 {"server":{"http_port":"127.0.0.1:8084","ice_servers":["stun:stun.l.google.com:19302"]},"streams":{}}
  780     0 root     S     2788   0%   1   0% /bin/bash
 1656     0 root     S     2788   0%   0   0% /bin/bash
 2261  1656 root     R     1672   0%   2   0% top
   24     1 root     S      204   0%   0   0% s6-supervise s6rc-fdholder
   61     1 root     S      204   0%   2   0% s6-supervise home-assistant
   15     1 root     S      204   0%   1   0% s6-supervise s6-linux-init-shutdownd
   25     1 root     S      204   0%   3   0% s6-supervise s6rc-oneshot-runner
    1     0 root     S      200   0%   0   0% /package/admin/s6/command/s6-svscan -d4 -- /run/service
   17    15 root     S      192   0%   0   0% /package/admin/s6-linux-init/command/s6-linux-init-shutdownd -c /run/s6/basedir -g 3000 -C -B
   33    25 root     S      180   0%   2   0% /package/admin/s6/command/s6-ipcserverd -1 -- /package/admin/s6/command/s6-ipcserver-access -v0 -E -l0 -i data/rules -- /package/admin/s6/comma
bash-5.1# py-spy top --pid 61
Error: Failed to find python version from target process
bash-5.1#

any help?

Hi
sure about the parameter for the PID? 61 is the PID of the parent process for homeassistant, you are likely trying to get information for PID 64 with py-spy?
py-spy top --pid 64

Edit: this worked for me too, uses pgrep to dynamically find the the pid for the “hass” process started by user “homeassistant” (if I recall correctly):
sudo py-spy top --pid $(pgrep -u homeassistant hass )
Armin

on the pid, check this guide I made how to get the correct one: Instructions to install Py-spy on HAOS

top (to get pid for homeassistant)

and just to be sure the guide was still accurate I dd test the exact same commands, and no errors appeared.

are you sure you have the correct pid, and file installed?
(I take it the docker exec went ok given the command prompt, and the folders are there too, given no cd error was displayed)