Merge pull request #1 from viroos/master

Update check_http_json.py
This commit is contained in:
Drew Kerrigan 2015-04-24 10:34:31 -04:00
commit 15a2909705

View File

@ -11,6 +11,8 @@ import httplib, urllib, urllib2
import json
import argparse
from pprint import pprint
from urllib2 import HTTPError
from urllib2 import URLError
class NagiosHelper:
@ -44,8 +46,8 @@ class JsonHelper:
self.data = json_data
def equals(self, key, value): return self.exists(key) and str(self.get(key)) == value
def lte(self, key, value): return self.exists(key) and str(self.get(key)) <= value
def gte(self, key, value): return self.exists(key) and str(self.get(key)) >= value
def lte(self, key, value): return self.exists(key) and float(self.get(key)) <= float(value)
def gte(self, key, value): return self.exists(key) and float(self.get(key)) >= float(value)
def exists(self, key): return (self.get(key) != (None, 'not_found'))
def get(self, key, temp_data=''):
"""Can navigate nested json keys with a dot format (Element.Key.NestedKey). Returns (None, 'not_found') if not found"""
@ -205,4 +207,4 @@ if __name__ == "__main__":
# Print Nagios specific string and exit appropriately
print nagios.getMessage()
exit(nagios.code)
exit(nagios.code)