Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[Home Assistant] HASS VM High CPU Usage on Proxmox

Since my Proxmox Server is also my HTPC in my living room, I noticed that suddenly the CPU fan become very noisy. When checking all LXCs and VMs, it turned out that the Home Assistant VW was the cause.

When checking the Supervisor logs, I saw that there was a docker container that got terminated. This semmed to match the CPU usage pattern I checked before.

To inspect the docker container via the Advanced SSH & Web Terminal add-on, you must disable the Protection mode first.

After that, simply run docker stats.

If there are no suspicious values, simply open some of the add-ons in another window and check how the values behave. In the above screenshot, I simply opened the VSCode editor, and you can immediately see an extreme high CPU usage. After a quick search, I found open issues that seem to be related to this issue:

As a workaround, a user had the idea to simply restart VSCode via an automation, when its CPU rises above a threshold. To do this, you have to enable some CPU & Memory sensors of the VSCode add-on. Search for your Home Assistant Supervisor Integration.

Select the Studio Code Server add-on.

And enable the sensors.

Now you can set up a simple automation like the following.

alias: Restart VSCode when cpu/memory too high
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.studio_code_server_cpu_percent
    for:
      hours: 0
      minutes: 5
      seconds: 0
    above: 50
  - trigger: numeric_state
    entity_id:
      - sensor.studio_code_server_memory_percent
    above: 30
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions: []
actions:
  - action: hassio.addon_restart
    metadata: {}
    data:
      addon: a0d7b954_vscode
mode: single

Since I have the automation setup, the Proxmox CPU fan is quiet again and the VM behaves normal.