8 def argv_to_dict(argv):
10 NOTE: very bare-bones, no error checking, will fail easily.
21 if __name__ == '__main__':
22 f = open("/tmp/myopsmail", 'a')
23 f.write("mail %s %s\n" % (time.time(), " ".join(sys.argv[1:])))
26 d = argv_to_dict(sys.argv[1:])
27 command_line="""/usr/bin/printf "%%b" "***** MyOpsNagios %(hostnotificationnumber)s *****\\n\\nNotification Type: %(notificationtype)s\\nHost: %(hostname)s\\nState: %(hoststate)s\\nAddress: %(hostaddress)s\\nInfo: %(hostoutput)s\\n\\nDate/Time: %(longdatetime)s\\n" | /bin/mail -S replyto=monitor@planet-lab.org -s "** %(notificationtype)s Host Alert: %(hostname)s is %(hoststate)s **" %(contactemail)s""" % d
28 os.system(command_line)