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
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | import smtplib |
---|
3 | from invirt.database import * |
---|
4 | from email.mime.text import MIMEText |
---|
5 | |
---|
6 | sender = 'Greg Price <price@mit.edu>' |
---|
7 | sendername = sender.split()[0] |
---|
8 | host = 'arklay-mansion' |
---|
9 | |
---|
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. |
---|
13 | |
---|
14 | Your VM %%s was running on %s. We have restarted it. |
---|
15 | |
---|
16 | We realize that this is an inconvenience for you, and we apologize for |
---|
17 | the unexpected downtime. |
---|
18 | |
---|
19 | - %s |
---|
20 | for the XVM team |
---|
21 | """ % (host, host, sendername) |
---|
22 | |
---|
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() |
---|
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>' |
---|
33 | msg['From'] = sender |
---|
34 | msg['Subject'] = '[xvm] Unexpected reboot of your VM %s' % vm |
---|
35 | s.sendmail(sender, |
---|
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.