Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- LOG=/tmp/ups.log
- fail_state=0
- restart=0
- while (:;); do
- capacity=`25volt | grep "capacity:"|awk '{print $2}'`
- voltage=`25volt |grep "voltage_in:" |awk '{print $2}'`
- /bin/echo -ne "BatLevel: $capacity Input_V: $voltage fail_state:${fail_state} restart:${restart}\r"
- if [ $voltage -le 190 ]; then
- if [ $fail_state -eq 0 ]; then
- /bin/echo -e "\nPower Lost on Server"
- fail_state=1
- fi;
- fi;
- if [ $fail_state -eq 1 ]; then
- if [ $capacity -le 20 ]; then
- /bin/echo -e "\nShutdown server"
- if [ $restart -eq 0 ]; then
- /sbin/shutdown -h +1
- fi;
- restart=1
- fi;
- if [ $voltage -gt 190 ]; then
- /bin/echo -e "\nPower Restore on Server"
- fail_state=0
- if [ $restart -eq 1 ]; then
- /sbin/shutdown -c
- restart=0
- fi;
- fi;
- fi;
- sleep 5
- done
Add Comment
Please, Sign In to add comment