mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-11-22 02:13:47 +01:00
Show returned JSON in OK Status when performance data is requested
This commit is contained in:
parent
1ac160e8c2
commit
c90b0323f5
@ -41,20 +41,23 @@ class NagiosHelper:
|
|||||||
critical_message = ''
|
critical_message = ''
|
||||||
unknown_message = ''
|
unknown_message = ''
|
||||||
|
|
||||||
def getMessage(self):
|
def getMessage(self, message=''):
|
||||||
"""
|
"""
|
||||||
Build a status-prefixed message with optional performance data
|
Build a status-prefixed message with optional performance data
|
||||||
generated externally
|
generated externally
|
||||||
"""
|
"""
|
||||||
|
|
||||||
text = "%s: Status %s." % (self.message_prefixes[self.getCode()],
|
message += self.warning_message
|
||||||
self.message_prefixes[self.getCode()])
|
message += self.critical_message
|
||||||
text += self.warning_message
|
message += self.unknown_message
|
||||||
text += self.critical_message
|
code = self.message_prefixes[self.getCode()]
|
||||||
text += self.unknown_message
|
output = "{code}: Status {code}. {message}".format(code=code, message=message.strip())
|
||||||
if self.performance_data:
|
if self.performance_data:
|
||||||
text += "|%s" % self.performance_data
|
output = "{code}: {perf_data} Status {code}. {message}|{perf_data}".format(
|
||||||
return text
|
code=code,
|
||||||
|
message=message.strip(),
|
||||||
|
perf_data=self.performance_data)
|
||||||
|
return output.strip()
|
||||||
|
|
||||||
def getCode(self):
|
def getCode(self):
|
||||||
code = OK_CODE
|
code = OK_CODE
|
||||||
|
@ -48,4 +48,4 @@ class NagiosHelperTest(unittest.TestCase):
|
|||||||
|
|
||||||
helper = NagiosHelper()
|
helper = NagiosHelper()
|
||||||
helper.performance_data = 'foobar'
|
helper.performance_data = 'foobar'
|
||||||
self.assertEqual('OK: Status OK.|foobar', helper.getMessage())
|
self.assertEqual('OK: foobar Status OK. |foobar', helper.getMessage())
|
||||||
|
Loading…
Reference in New Issue
Block a user