Mercurial > hg > python
diff nag.py @ 0:fee51ab07d09
blanket publication of all existing python files in lib/python on maritain
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Mon, 09 Mar 2020 14:58:04 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nag.py Mon Mar 09 14:58:04 2020 +0000 @@ -0,0 +1,24 @@ +#!/bin/python +# Create a Clockwork object using your API key +from clockwork import clockwork +from sys import stdin +from rfc822 import Message + +msg=Message(stdin,False) + +frm=msg.get('from') +if (frm!="nagios@nagios2.skywalker.privatedns.com" and frm!='"Henry S. Thompson" <ht@inf.ed.ac.uk>'): + print "SMS not from nagios: %s"%frm + exit(1) + +api = clockwork.API("0a778e372c3582eeef36b5f7f580113067e82d76") +message = clockwork.SMS( to = "447866471388", + message = msg.fp.read(), + from_name="Nagios") +response = api.send(message) + +if response.success: + print "SMS sent %s"%response.id +else: + print "SMS failed %s: %s"%(response.error_code,response.error_description) + exit(2)