source: trunk/scripts/outage/outage-mail @ 2251

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
2import smtplib
3from invirt.database import *
4from email.mime.text import MIMEText
5
6sender = 'Greg Price <price@mit.edu>'
7sendername = sender.split()[0]
8host = 'arklay-mansion'
9
10message = """\
11One of the four XVM host servers, %s, failed tonight at
12about 23:17 and was rebooted.  We're working to understand the cause.
13
14Your VM %%s was running on %s.  We have restarted it.
15
16We realize that this is an inconvenience for you, and we apologize for
17the unexpected downtime.
18
19- %s
20for the XVM team
21""" % (host, host, sendername)
22
23vms = "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
25def 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
39connect()
40s = smtplib.SMTP()
41s.connect()
42
43for vm in vms:
44    send_mail(vm)
45
46s.close()
Note: See TracBrowser for help on using the repository browser.