Won’t a command line sensor or even glances return that for you/
Glances has too much overhead (if it is possible).
For the command line see:
OK so I use HA dockermon with curl that returns memory used for addons… Maybe look at that? Returns a bunch or other stats as well.
Will do. Thanks.
Nice toy @DavidFW1960 — exposed API to docker is pretty cool.
@tom_l the thing I posted is really for “start-up” logic of the add-on and HA. It’s not really made to be a sensor because there’s no real output here (well except an actual file). I guess what you could do is indeed spit out a file to /backup and have HA parse it. If you want to execute something every X then take a look at the Linux “watch” command.
Making some progress. Any further comments should be made over here to prevent derailing this topic.
I modified the command in the 1st post to have a bit more logic where it checks if swap is already on with dmesg and if so NOT to repeat the command. Otherwise the SSH add-on fails a restart… So this new update should make bullet-proof. Famous last words
Thanks for putting this up here in the forums as well!
Hi I have tried to put the string in the Addon
This is my configuration:
authorized_keys:XXXXXXXXXX
password: ‘’
server:
tcp_forwarding: false
init_commands: >-
if [ ! -f /backup/_swap.swap ]; then fallocate -l 4G /backup/_swap.swap &&
mkswap /backup/_swap.swap && chmod 0600 /backup/_swap.swap && swapon
/backup/_swap.swap ; elif [[ ! $(dmesg|grep _swap.swap) = swap on ]]; then
swapon /backup/_swap.swap; fi
But when it starts says this:
21-02-25 17:06:01 WARNING (MainThread) [supervisor.addons.options] Unknown options init_commands
How can i fix it.
Thanks
Sorry for my english.
Take a screenshot of the entire thing… either formatting is involved or you’re using the wrong addon.
Please see bullet #2 in the first post… you installed the wrong add-on
I’m just trying to go through this. My config for SSH & Web Terminal looks like this:
Is there anything else I have to do? Like creating the /backup folder or _swap.swap file?
I’m just a bit confused. I have a graph on my Overview showing free Swap space and it looks like this:
Have I got everything right?
Cheers
Andy
Looks like you got it all right. I would open up the shell and run the command htop… On the top left you will swap space and it should be bigger than the 200MB’s that I believe is done by default. Here’s a screenshot of mine:
Thank you. Yes, mine looks fine. It’s just that it never seems to change so it doesn’t look like it’s being used.
Wow, great. Made my day after the second host reboot within 3 days due to swap above 80%
Thanks a lot!
Now I can wait until the home assistant blue! is available.
@jzhass Hi, today there was an update for the terminal ssh.
After the restart, I got this protokoll:
[cont-init.d] ssh.sh: exited 0.
[cont-init.d] user.sh: executing...
[08:16:32] NOTICE: Session sharing has been disabled!
swapon: /backup/_swap.swap: Resource busy
[08:16:33] FATAL: Failed executing init command: if [ ! -f /backup/_swap.swap ]; then fallocate -l 2G /backup/_swap.swap && mkswap /backup/_swap.swap && chmod 0600 /backup/_swap.swap && swapon /backup/_swap.swap ; elif [[ ! $(dmesg|grep _swap.swap) = *swap\ on* ]]; then swapon /backup/_swap.swap; fi
[cont-init.d] user.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing...
-----------------------------------------------------------
Oops! Something went wrong.
We are so sorry, but something went terribly wrong when
starting or running this add-on.
Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
s6-nuke: fatal: unable to kill: No such process
I deleted the init command, Started successful and added it again.
packages: []
init_commands:
- >-
if [ ! -f /backup/_swap.swap ]; then fallocate -l 2G /backup/_swap.swap &&
mkswap /backup/_swap.swap && chmod 0600 /backup/_swap.swap && swapon
/backup/_swap.swap ; elif [[ ! $(dmesg|grep _swap.swap) = *swap\ on* ]];
then swapon /backup/_swap.swap; fi
My question: will the addon be restarted during a normal HA restart or only when the host is restarted?
In the last case, the init command is only needed for a host restart. Can I let the command in the configuration so that it is used in case of a complete restart?
Have you tried restarting the host and seeing if htop command shows the swap space you expect to see?
Hi, no. I only restarted the terminal.
As the swap file was already there, the terminal started without the init command and everything was fine.
My question is, what will happen with this swap file in case of a ha host restart?
Will the swap file be dropped and new initiated with basic size or will the swap file be kept as it is.
In the last case, I can empty the init_command and only get it back, when I have to create a new file used (new installation).
Obviously I havent understood the command completely
I think my point was no clear… take a host reboot and let me know if all is okay or if you still get the error.
If the swap file is there it will not create it but it will try to “use” it. In your case it may already be used. When in doubt just take a host reboot and see if the problem is still there.