comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:fee51ab07d09
1 #!/bin/python
2 # Create a Clockwork object using your API key
3 from clockwork import clockwork
4 from sys import stdin
5 from rfc822 import Message
6
7 msg=Message(stdin,False)
8
9 frm=msg.get('from')
10 if (frm!="nagios@nagios2.skywalker.privatedns.com" and frm!='"Henry S. Thompson" <ht@inf.ed.ac.uk>'):
11 print "SMS not from nagios: %s"%frm
12 exit(1)
13
14 api = clockwork.API("0a778e372c3582eeef36b5f7f580113067e82d76")
15 message = clockwork.SMS( to = "447866471388",
16 message = msg.fp.read(),
17 from_name="Nagios")
18 response = api.send(message)
19
20 if response.success:
21 print "SMS sent %s"%response.id
22 else:
23 print "SMS failed %s: %s"%(response.error_code,response.error_description)
24 exit(2)