Python appears to be part of at least the SSH addon container if not the base OS. I was able to pip3 install docker but then everything in home assistant got wobbly and I had to reboot. Next I tried a virtual environment and modified the check_mk_agent to activate it. At that point, the checks stopped completing. I gave up on that whole approach since even if the container is running, it doesn’t tell me if my automation failed or if my Sonos is offline (happened last month due to a bug in that integration).
I’ve got working code talking to the HA API. It doesn’t lend itself to easy monitoring. In my case, I’m using Cisco Mobility Express as a device tracker, so every single client shows up as an entity. If I add a new device, discovery will warn on it until I either create a discovery rule or mark it unmonitored. The state information for each device is specific to that device class. Some are numeric measurements, some are text. It will be a trial and error exercise to determine proper state for each device class unless perhaps I can find a decoder ring somewhere in the entity data. I’m only a couple hours into this so there may be a breakthrough waiting.
There is also the observer on http port 4357. It provides 3 very basic status messages for HA subsystems. Since looking at that should be a prerequisite before checking entities, I will likely just start there with beautifulsoup or another web scraper.
Just to expand upon this, if you are running HAOS, you can get more accurate stats by running the below in the Individual program call instead of agent access after enabling SSH access to the host as mentioned here:
(Assuming check_mk_agent has been copied over to /config/check_mk_agent)
Quite interesting indeed. I just never noticed it, but you’re right. It did report the memory in a strange way. But I wonder if it’s reported right this way as well. I run my HA on Proxmox and this is what I get for memory usage:
As you can see, there’s quite a difference between what is claimed from within the HA docker containder and what Proxmox actually tells me. Quite confusing this.
I think the discrepancy is due to it still running within a container, this time from within the homeassistant container and not the SSH addon.
I’ve did some further testing and able to now pull stats from HAOS itself allowing more accurate resource monitoring.
I copied the check_mk_agent to /mnt/data/ within HAOS however when running, it produced errors relating to illegal ‘-f’ option for some export commands. I removed the -f flag from the following lines within the check_mk_agent (lines 381-383) which allows it to run successfully:
Hi folks! I’ve following up on these steps and got to actually trying to run check_mk_agent in the HAOS. It unfortunaly fails:
# /mnt/data/check_mk_agent
/mnt/data/check_mk_agent: line 340: syntax error: bad for loop variable
the code is for converting hex:
hex_decode() {
# We might not have xxd available, so we have to do it manually.
# Be aware that this implementation is very slow and should not be used for large data.
local hex="$1"
for ((i = 0; i < ${#hex}; i += 2)); do
printf '%b' "\x${hex:i:2}"
done
}
I’ve experimented a bit and it seems HAOS shell doesn’t like the (( operator. In fact, when I converted this function into sh-compatible the the check_mk_agent run a bit further (and failed on some other piece of code).
I think HAOS version of bash is an undercover busybox. None of bash --version or similar return the bash version. However, the binary is linked to busybox libs: