Biduleohm

UPS report

Mar 4th, 2015
2,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.84 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 ""
  21.     date "+Time: %Y-%m-%d %H:%M:%S"
  22.     echo "UPS Status: `upsc ${ups} ups.status`"
  23.     echo "Output Load: `upsc ${ups} ups.load` %"
  24.     echo "Output Voltage: `upsc ${ups} output.voltage` V"
  25.     echo "Battery Runtime: `upsc ${ups} battery.runtime` s"
  26.     echo "Battery Charge: `upsc ${ups} battery.charge` %"
  27.     echo ""
  28.     echo "</pre>"
  29. ) >> ${logfile}
  30.  
  31. ### Send report ###
  32. sendmail -t < ${logfile}
  33. rm ${logfile}
Advertisement
Add Comment
Please, Sign In to add comment