Guest User

Untitled

a guest
Jul 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/bin/sh
  2. LOG=/tmp/ups.log
  3.  
  4.  
  5. fail_state=0
  6. restart=0
  7.  
  8. while (:;); do
  9. capacity=`25volt | grep "capacity:"|awk '{print $2}'`
  10. voltage=`25volt |grep "voltage_in:" |awk '{print $2}'`
  11. /bin/echo -ne "BatLevel: $capacity Input_V: $voltage fail_state:${fail_state} restart:${restart}\r"
  12.  
  13. if [ $voltage -le 190 ]; then
  14. if [ $fail_state -eq 0 ]; then
  15. /bin/echo -e "\nPower Lost on Server"
  16. fail_state=1
  17. fi;
  18. fi;
  19.  
  20. if [ $fail_state -eq 1 ]; then
  21. if [ $capacity -le 20 ]; then
  22. /bin/echo -e "\nShutdown server"
  23. if [ $restart -eq 0 ]; then
  24. /sbin/shutdown -h +1
  25. fi;
  26. restart=1
  27.  
  28. fi;
  29. if [ $voltage -gt 190 ]; then
  30. /bin/echo -e "\nPower Restore on Server"
  31. fail_state=0
  32. if [ $restart -eq 1 ]; then
  33. /sbin/shutdown -c
  34. restart=0
  35. fi;
  36. fi;
  37. fi;
  38. sleep 5
  39. done
Add Comment
Please, Sign In to add comment