Created
October 21, 2012 21:13
-
-
Save scragg0x/3928527 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Check status of a 3ware RAID and alert using AMAZON SES | |
| Requires tw_cli binary | |
| http://www.cyberciti.biz/files/tw_cli.8.html | |
| Author: Matthew Scragg <[email protected]> | |
| """ | |
| import subprocess | |
| status = subprocess.check_output("tw_cli info c4 u0 | egrep ^u0[^\/] | awk '{ print $3 }'", shell=True).rstrip().split("\n"); | |
| alert = 0 | |
| for line in status: | |
| if line != "OK": | |
| alert = 1 | |
| if alert == 1: | |
| status = subprocess.check_output("tw_cli info c4 u0", shell=True).rstrip() | |
| from boto.ses.connection import SESConnection | |
| import sys | |
| sender = '[email protected]' | |
| destination = ['[email protected]'] | |
| KEY = "" | |
| SECRET = "" | |
| content=status | |
| subject="LSN DB - RAID ERROR" | |
| try: | |
| conn = SESConnection(KEY, SECRET) | |
| conn.send_email(sender, subject, content, destination) | |
| except Exception, exc: | |
| sys.exit( "mail failed; %s" % str(exc) ) # give a error messag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment