From eab5b7065ba411ccb0560dcf26b455f1a1312a06 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 26 Mar 2009 01:32:18 -0400 Subject: [PATCH] outage-mail: send xvm@ just one message for the whole batch svn path=/trunk/scripts/outage/; revision=2276 --- outage-mail | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/outage-mail b/outage-mail index 84ba26e..4731cb5 100644 --- a/outage-mail +++ b/outage-mail @@ -17,12 +17,22 @@ def send_mail(smtp, opts, message, vm): contact += '@mit.edu' msg = MIMEText(message % vm) msg['To'] = contact - msg['CC'] = 'XVM ' - msg['Reply-To'] = 'XVM ' msg['From'] = opts.from_addr + msg['Reply-To'] = 'XVM ' msg['Subject'] = opts.subject % vm smtp.sendmail(opts.from_addr, - [contact, 'xvm@mit.edu'], + [contact], + msg.as_string()) + return msg.as_string() + +def send_summary(smtp, opts, messages): + msg = MIMEText('\n\n\n'.join(messages)) + msg['To'] = 'xvm@mit.edu' + msg['From'] = opts.from_addr + msg['Subject'] = ("xvm outage-mail summary (%d): %s" + % (len(messages), opts.subject)) + smtp.sendmail(opts.from_addr, + ['xvm@mit.edu'], msg.as_string()) def main(argv): @@ -65,8 +75,10 @@ def main(argv): s = smtplib.SMTP() s.connect() + messages = [] for vm in vms: - send_mail(s, opts, message, vm) + messages.append(send_mail(s, opts, message, vm)) + send_summary(s, opts, messages) s.close() -- 1.7.9.5