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

Last change on this file since 2250 was 2250, checked in by price, 15 years ago

import Evan's outage-mail script

File size: 1.3 KB
Line 
1import smtplib
2from invirt.database import *
3from email.mime.text import MIMEText
4
5message = """One of the four XVM servers, aperture-science, spontaneously rebooted
6today at around 2:55 today. As of now, we're not sure what the cause of
7this was.
8
9Your VM %s was running on aperture-science. We have restarted it.
10
11We realize that this is an inconvenience for you, and we apologize for
12the unexpected downtime.
13
14- Evan
15for the XVM team"""
16
17vms = "nforrest0 remus ghost-of-golezan tabbott 6470 dh moo mclamb dt-web htns uav-team x lsmb twopi what esg panache gardiner mailman-acl jack-o-tron knowledge ephialtes ocaml happy-go-lucky maridia cochese ocelot ecprice bibix groovy r privoxy thebes intrepid-paravirt-test qren2 quentin woodrow prolix oculus shinnyih gkovacs".split()
18
19def send_mail(vm):
20    contact = Machine.query.filter_by(name=vm).first().contact
21    if '@' not in contact:
22        contact += '@mit.edu'
23    msg = MIMEText(message % vm)
24    msg['To'] = contact
25    msg['CC'] = 'XVM <xvm@mit.edu>'
26    msg['Reply-To'] = 'XVM <xvm@mit.edu>'
27    msg['From'] = 'Evan Broder <broder@mit.edu>'
28    msg['Subject'] = '[xvm] Unexpected reboot of your VM %s' % vm
29    s.sendmail('Evan Broder <broder@mit.edu>',
30        [contact, 'xvm@mit.edu'],
31        msg.as_string())
32
33connect()
34s = smtplib.SMTP()
35s.connect()
36
37for vm in vms:
38    send_mail(vm)
39
40s.close()
Note: See TracBrowser for help on using the repository browser.