mirror of
https://github.com/drewkerrigan/nagios-http-json.git
synced 2024-11-21 09:53:50 +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 = ''
|
||||
unknown_message = ''
|
||||
|
||||
def getMessage(self):
|
||||
def getMessage(self, message=''):
|
||||
"""
|
||||
Build a status-prefixed message with optional performance data
|
||||
generated externally
|
||||
"""
|
||||
|
||||
text = "%s: Status %s." % (self.message_prefixes[self.getCode()],
|
||||
self.message_prefixes[self.getCode()])
|
||||
text += self.warning_message
|
||||
text += self.critical_message
|
||||
text += self.unknown_message
|
||||
message += self.warning_message
|
||||
message += self.critical_message
|
||||
message += self.unknown_message
|
||||
code = self.message_prefixes[self.getCode()]
|
||||
output = "{code}: Status {code}. {message}".format(code=code, message=message.strip())
|
||||
if self.performance_data:
|
||||
text += "|%s" % self.performance_data
|
||||
return text
|
||||
output = "{code}: {perf_data} Status {code}. {message}|{perf_data}".format(
|
||||
code=code,
|
||||
message=message.strip(),
|
||||
perf_data=self.performance_data)
|
||||
return output.strip()
|
||||
|
||||
def getCode(self):
|
||||
code = OK_CODE
|
||||
|
@ -48,4 +48,4 @@ class NagiosHelperTest(unittest.TestCase):
|
||||
|
||||
helper = NagiosHelper()
|
||||
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