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.

[ABAP] Export to memory / Import from memory

Exporting:

DATA: l_p0001  TYPE p0001,
      l_return TYPE bapireturn1.

"...

DATA(l_guid) = cl_system_uuid=>create_uuid_c32_static( ).       
 
EXPORT p0001 = l_p0001 TO MEMORY ID l_guid.
SUBMIT z_hr_report WITH p_guid = l_guid AND RETURN.
IMPORT return = l_return FROM MEMORY ID l_guid.

Importing:

REPORT z_hr_report.

PARAMETERS p_guid TYPE sysuuid_c32.

DATA: l_p0001  TYPE p0001,
      l_return TYPE bapireturn1.

START-OF-SELECTION.

IMPORT p0001 = l_p0001 FROM MEMORY ID p_guid.
CHECK sy-subrc = 0.

"do stuff...
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
  EXPORTING
    number = l_p0001-pernr
  IMPORTING
    return = l_return.

IF l_return-type = 'E'.
  EXPORT return = l_return TO MEMORY ID p_guid.
  RETURN.
ENDIF.