seesam

UPS readout Shellscript for Freenas

Mar 19th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ### Parameters ###
  4. logfile="/tmp/ups_report.tmp"
  5. subject="UPS Status Report for FreeNAS"
  6. ups="ups@localhost"
  7.  
  8. ### Set email headers ###
  9. (
  10. echo "To: ${email}"
  11. echo "Subject: ${subject}"
  12. echo "Content-Type: text/html"
  13. echo "MIME-Version: 1.0"
  14. echo -e "\r\n"
  15. ) > ${logfile}
  16.  
  17. ### Set email body ###
  18. (
  19. echo "<pre style=\"font-size:14px\">"
  20. echo "UPS report generated:"
  21. date "+Time: %Y-%m-%d %H:%M:%S"
  22. echo ""
  23. echo "Ups Info:"
  24. echo " UPS Status: `upsc ${ups} ups.status`"
  25. echo " UPS Temp: `upsc ${ups} ups.temperature` C"
  26. echo ""
  27. echo "Input Output:"
  28. echo " Input Frequency: `upsc ${ups} input.frequency` Hz"
  29. echo " Input Voltage: `upsc ${ups} input.voltage` V"
  30. echo " Output Voltage: `upsc ${ups} output.voltage` V"
  31. echo " Output Load: `upsc ${ups} ups.load` %"
  32. echo ""
  33. echo "Battery Status:"
  34. echo " Battery Runtime: `upsc ${ups} battery.runtime` s"
  35. echo " Battery Voltage: `upsc ${ups} battery.voltage` V"
  36. echo " Battery Charge: `upsc ${ups} battery.charge` %"
  37. echo ""
  38. echo "</pre>"
  39. ) >> ${logfile}
  40.  
  41. ### Send report ###
  42. sendmail -t < ${logfile}
  43. rm ${logfile}
Advertisement
Add Comment
Please, Sign In to add comment