more comfort
This commit is contained in:
+30
-4
@@ -2,22 +2,48 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import httplib, urllib
|
import httplib, urllib
|
||||||
|
import getopt
|
||||||
|
|
||||||
def pushover(msg):
|
def pushover(msg, title=""):
|
||||||
conn = httplib.HTTPSConnection("api.pushover.net:443")
|
conn = httplib.HTTPSConnection("api.pushover.net:443")
|
||||||
conn.request("POST", "/1/messages.json",
|
conn.request("POST", "/1/messages.json",
|
||||||
urllib.urlencode({
|
urllib.urlencode({
|
||||||
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
|
"token": "aNY2xeYydxzabzihTjb3P2LMHhqhr2",
|
||||||
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
|
"user": "uDhH33UjQQDYtNzJb1ThRiWb9ingGK",
|
||||||
"message": msg,
|
"message": msg,
|
||||||
|
"title": title,
|
||||||
}), { "Content-type": "application/x-www-form-urlencoded" })
|
}), { "Content-type": "application/x-www-form-urlencoded" })
|
||||||
r1=conn.getresponse()
|
r1=conn.getresponse()
|
||||||
#print r1.status, r1.reason
|
#print r1.status, r1.reason
|
||||||
return r1.status == 200
|
return r1.status == 200
|
||||||
|
|
||||||
|
|
||||||
v=" ".join(sys.argv[1:])
|
#
|
||||||
if pushover(v):
|
# Main
|
||||||
|
#
|
||||||
|
|
||||||
|
helpflag=False
|
||||||
|
verbose=False
|
||||||
|
title="Nagios"
|
||||||
|
|
||||||
|
optslist, args = [], []
|
||||||
|
try:
|
||||||
|
optslist, args = getopt.getopt(sys.argv[1:], 'ht:v')
|
||||||
|
except getopt.error, cause:
|
||||||
|
helpflag=True
|
||||||
|
|
||||||
|
lastyear=0
|
||||||
|
for o,a in optslist:
|
||||||
|
if o == '-v':
|
||||||
|
verbose=True
|
||||||
|
elif o == '-t':
|
||||||
|
title=a
|
||||||
|
|
||||||
|
|
||||||
|
v=" ".join(args)
|
||||||
|
rc=pushover(v, title)
|
||||||
|
if verbose:
|
||||||
|
if rc:
|
||||||
print "delivered"
|
print "delivered"
|
||||||
else:
|
else:
|
||||||
print "NOT delivered"
|
print "NOT delivered"
|
||||||
|
|||||||
Reference in New Issue
Block a user