-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextsecure-via-http
More file actions
executable file
·32 lines (26 loc) · 1.17 KB
/
Copy pathtextsecure-via-http
File metadata and controls
executable file
·32 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
# TextSecure using HTTP Gateway
# Notification via TextSecure using HTTP Gateway
import os, sys, requests
if os.environ['NOTIFY_WHAT'] == 'SERVICE':
if os.environ['NOTIFY_SERVICESTATE'] == "OK":
message = "\U00002705".decode("unicode-escape")
elif os.environ['NOTIFY_SERVICESTATE'] == "WARNING":
message = "\U000026A0".decode("unicode-escape")
elif os.environ['NOTIFY_SERVICESTATE'] == "CRITICAL":
message = "\U0000274C".decode("unicode-escape")
elif os.environ['NOTIFY_SERVICESTATE'] == "UNKNOWN":
message = "\U00002734".decode("unicode-escape")
else:
message = ""
message += " " + os.environ['NOTIFY_HOSTNAME'] + " "
message += os.environ['NOTIFY_SERVICESTATE'] + " "
message += os.environ['NOTIFY_SERVICEDESC'] + " "
message += os.environ['NOTIFY_SERVICEOUTPUT']
else:
message += "is " + os.environ['NOTIFY_HOSTSTATE']
recipient = os.environ['NOTIFY_CONTACTPAGER']
if not recipient:
sys.stderr.write('Error: No contact pager set for %s\n' % os.environ['NOTIFY_CONTACTNAME'])
sys.exit(1)
requests.post(os.environ['NOTIFY_PARAMETER_1'], data={'message': message, 'to': recipient})