停电UPS供电情况下自动关机

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

action=`ping -c 20 -W 1 192.168.1.1 | grep received | awk '{print $4}'`

if [ $action -eq 0 ];then
echo `date`  "Check Gateway Fail!" >> /var/log/power.log
shutdown -p now
else
echo `date`  "Power OK" >> /var/log/power.log
fi