From: Greg Price Date: Tue, 17 Mar 2009 00:26:10 +0000 (-0400) Subject: import Evan's outage-mail script X-Git-Url: http://xvm.mit.edu/gitweb/invirt/scripts/outage.git/commitdiff_plain/5537f3877fdae638164e06ad45b4f88e27c5093b import Evan's outage-mail script svn path=/trunk/scripts/outage/; revision=2250 --- 5537f3877fdae638164e06ad45b4f88e27c5093b diff --git a/outage-mail b/outage-mail new file mode 100644 index 0000000..4968135 --- /dev/null +++ b/outage-mail @@ -0,0 +1,40 @@ +import smtplib +from invirt.database import * +from email.mime.text import MIMEText + +message = """One of the four XVM servers, aperture-science, spontaneously rebooted +today at around 2:55 today. As of now, we're not sure what the cause of +this was. + +Your VM %s was running on aperture-science. We have restarted it. + +We realize that this is an inconvenience for you, and we apologize for +the unexpected downtime. + +- Evan +for the XVM team""" + +vms = "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() + +def send_mail(vm): + contact = Machine.query.filter_by(name=vm).first().contact + if '@' not in contact: + contact += '@mit.edu' + msg = MIMEText(message % vm) + msg['To'] = contact + msg['CC'] = 'XVM ' + msg['Reply-To'] = 'XVM ' + msg['From'] = 'Evan Broder ' + msg['Subject'] = '[xvm] Unexpected reboot of your VM %s' % vm + s.sendmail('Evan Broder ', + [contact, 'xvm@mit.edu'], + msg.as_string()) + +connect() +s = smtplib.SMTP() +s.connect() + +for vm in vms: + send_mail(vm) + +s.close()