mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-11-22 10:23:50 +01:00
commit
15a2909705
@ -11,6 +11,8 @@ import httplib, urllib, urllib2
|
|||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
from urllib2 import HTTPError
|
||||||
|
from urllib2 import URLError
|
||||||
|
|
||||||
|
|
||||||
class NagiosHelper:
|
class NagiosHelper:
|
||||||
@ -44,8 +46,8 @@ class JsonHelper:
|
|||||||
self.data = json_data
|
self.data = json_data
|
||||||
|
|
||||||
def equals(self, key, value): return self.exists(key) and str(self.get(key)) == value
|
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 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 str(self.get(key)) >= 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 exists(self, key): return (self.get(key) != (None, 'not_found'))
|
||||||
def get(self, key, temp_data=''):
|
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"""
|
"""Can navigate nested json keys with a dot format (Element.Key.NestedKey). Returns (None, 'not_found') if not found"""
|
||||||
|
Loading…
Reference in New Issue
Block a user