Last change
on this file since 2251 was
2251,
checked in by price, 16 years ago
|
outage-mail: small improvements, mostly update for tonight's outage
|
File size:
1.3 KB
|
Rev | Line | |
---|
[2251] | 1 | #!/usr/bin/python |
---|
[2250] | 2 | import smtplib |
---|
| 3 | from invirt.database import * |
---|
| 4 | from email.mime.text import MIMEText |
---|
| 5 | |
---|
[2251] | 6 | sender = 'Greg Price <price@mit.edu>' |
---|
| 7 | sendername = sender.split()[0] |
---|
| 8 | host = 'arklay-mansion' |
---|
[2250] | 9 | |
---|
[2251] | 10 | message = """\ |
---|
| 11 | One of the four XVM host servers, %s, failed tonight at |
---|
| 12 | about 23:17 and was rebooted. We're working to understand the cause. |
---|
[2250] | 13 | |
---|
[2251] | 14 | Your VM %%s was running on %s. We have restarted it. |
---|
| 15 | |
---|
[2250] | 16 | We realize that this is an inconvenience for you, and we apologize for |
---|
| 17 | the unexpected downtime. |
---|
| 18 | |
---|
[2251] | 19 | - %s |
---|
| 20 | for the XVM team |
---|
| 21 | """ % (host, host, sendername) |
---|
[2250] | 22 | |
---|
[2251] | 23 | vms = "amd64-test brain-trust cluster-test david-vista debathena-livecd-build ecprice gradbook greg-ns1 greg-ns2 groovy htns iodine jsoltren latex liftm medkaz mhd mksvn niska polarix price-lenny price-test8 qren2 shawn-of-awesome staxowax tdc tdc-secure thesecrete tor transistor watmap".split() |
---|
[2250] | 24 | |
---|
| 25 | def send_mail(vm): |
---|
| 26 | contact = Machine.query.filter_by(name=vm).first().contact |
---|
| 27 | if '@' not in contact: |
---|
| 28 | contact += '@mit.edu' |
---|
| 29 | msg = MIMEText(message % vm) |
---|
| 30 | msg['To'] = contact |
---|
| 31 | msg['CC'] = 'XVM <xvm@mit.edu>' |
---|
| 32 | msg['Reply-To'] = 'XVM <xvm@mit.edu>' |
---|
[2251] | 33 | msg['From'] = sender |
---|
[2250] | 34 | msg['Subject'] = '[xvm] Unexpected reboot of your VM %s' % vm |
---|
[2251] | 35 | s.sendmail(sender, |
---|
[2250] | 36 | [contact, 'xvm@mit.edu'], |
---|
| 37 | msg.as_string()) |
---|
| 38 | |
---|
| 39 | connect() |
---|
| 40 | s = smtplib.SMTP() |
---|
| 41 | s.connect() |
---|
| 42 | |
---|
| 43 | for vm in vms: |
---|
| 44 | send_mail(vm) |
---|
| 45 | |
---|
| 46 | s.close() |
---|
Note: See
TracBrowser
for help on using the repository browser.