I've tried to change low=1:high=2 to low=0:high=0
but I haven't got *Off* current state for this sensor from sensord:
- hw.sensors.upd0.indicator2=On (ACPresent), OK
Even for AC disconnected sensord repors that ACPresent is *On*,
however when I look for
- sysctl hw.sensors.upd0.indicator2
it repororts that ACPresent is *Off*, so I decided don't rely
on sensord logic and place own script to cron and execute it
every minute.
#!/bin/sh
if [ -f /tmp/powerout.lock ]; then
exit 0
fi
ACstatus () {
sysctl hw.sensors.upd0.indicator2 | cut -c28-29 | grep -q "On" > /dev/null
}
i=0
if ACstatus ; then
exit 0
else
logger -t UPS "AC has been disconnected"
touch /tmp/powerout.lock
/usr/local/bin/mutt -s "Power outage in office" -- ad...@example.com
< /root/powerout
while [ $i -lt "360" ]
do
i=$((i+60))
sleep 60
if ACstatus ; then
logger -t UPS "AC has been connected again after ${i} seconds."
/usr/local/bin/mutt -s "Power returned in office" --
ad...@example.com
rm -rf /tmp/powerout.lock
exit 0
else
if [ "$i" -eq "300" ]; then
/usr/local/bin/mutt -s "No power for 5 min. System is
shutting down now." -- ad...@example.com
logger -t UPS "System is shutting down now."
shutdown -hp +0
fi
fi
done
fi