Advertisement
Biduleohm

UPS report

Mar 4th, 2015
1,965
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. email="your_email@gmail.com"
  6. subject="UPS Status Report for FreeNAS"
  7. ups="ups@localhost"
  8.  
  9. ### Set email headers ###
  10. (
  11.     echo "To: ${email}"
  12.     echo "Subject: ${subject}"
  13.     echo "Content-Type: text/html"
  14.     echo "MIME-Version: 1.0"
  15.     echo -e "\r\n"
  16. ) > ${logfile}
  17.  
  18. ### Set email body ###
  19. (
  20.     echo "<pre style=\"font-size:14px\">"
  21.     echo ""
  22.     date "+Time: %Y-%m-%d %H:%M:%S"
  23.     echo "UPS Status: `upsc ${ups} ups.status`"
  24.     echo "Output Load: `upsc ${ups} ups.load` %"
  25.     echo "Output Voltage: `upsc ${ups} output.voltage` V"
  26.     echo "Battery Runtime: `upsc ${ups} battery.runtime` s"
  27.     echo "Battery Charge: `upsc ${ups} battery.charge` %"
  28.     echo ""
  29.     echo "</pre>"
  30. ) >> ${logfile}
  31.  
  32. ### Send report ###
  33. sendmail -t < ${logfile}
  34. rm ${logfile}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement