Hi!
Some systems I have take some time to shut down, so I would like them to shut down if the UPS have been on battery for 2 minutes. Internet has told me that SHUTDOWNCMD “/sbin/shutdown -h +0” in /etc/nut/upsmon.conf will execute when the UPS is both OB (on battery) and LB (Low battery). Like in wiki.ipfire.org - Detailed NUT Configuration<https://wiki.ipfire.org/addons/nut/detailed> where it says “SHUTDOWNCMD “/sbin/shutdown -h +0” this command will be triggered if UPS sends the BL (Battery Low) flag.” But I would like to be on the safest side, and not hope “low battery” is enough time to shut down. So 2 minutes sound much more safe for paranoid me. I do not know much about NUT, but after some Googling, one idea I have is to in /etc/nut/upsmon.conf on client change to this NOTIFYCMD "/etc/nut/shutdown_script.sh" NOTIFYFLAG ONBATT EXEC And then in /etc/nut/shutdown_script.sh have something like this #!/bin/bash poll_interval=5 wait_time=120 counter=0 no_wait_time=60 no_counter=0 while true do output=$(upsc qnapups@192.168.222.252 ups.status) if echo "$output" | grep -q "OB" then counter=$((counter + poll_interval)) no_counter=0 else counter=0 no_counter=$((no_counter + poll_interval)) fi if [ $counter -ge $wait_time ] then echo "Still outoput OB = On Battery, after 2 min. I will now shut down" # Here I will shutdown the system # "/sbin/shutdown -h +0" break fi if [ $no_counter -ge $no_wait_time ] then echo "Have not seen OB for 1 min, so quiting the script" break fi sleep $poll_interval done But now I am starting to wonder if I am overdoing this. Surely there must already be a ready-made solution for this in NUT somewhere, but I have just searched with wrong words i Google. Have any of you done something similar with NUT, and what is the right way to do it? /raffe
_______________________________________________ Nut-upsuser mailing list Nut-upsuser@alioth-lists.debian.net https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser