Archived
1
0

Nagios/Icinga Plugin output improvements

* Do not longer print "YUM <status>: " in the Nagios/Icinga plugin output.
  This change was made gor the reasons of, and following my own proposal at http://sourceforge.net/tracker/?func=detail&aid=3572875&group_id=29880&atid=397597 , which already got consent by at lead developers from at least Nagios.
* If there is no performance data, do not print "|" in the Nagios/Icinga plugin output.
  Currently, check_yum never gives performance data output anyway and even if this would be the case, there may be statuses for which no performance data is applicable (typically when the status would be UNKNOWN).
  As this simplyfies parsing of the plugin output by Nagios/Icinga, it seemed useful.
This commit is contained in:
Christoph Anton Mitterer 2012-09-30 00:38:01 +02:00
parent 8066a05f6d
commit 38442b4731

View File

@ -27,21 +27,21 @@ from optparse import OptionParser
DEFAULT_TIMEOUT = 30
def end(status, message, perfdata=''):
def end(status, message, perfdata=""):
"""Exits the plugin with first arg as the return code and the second arg as the message to output."""
check = "YUM "
if perfdata:
print "%s | %s" % (message, perfdata)
else:
print "%s" % message
if status == OK:
print "%sOK: %s | %s" % (check, message, perfdata)
sys.exit(OK)
elif status == WARNING:
print "%sWARNING: %s | %s" % (check, message, perfdata)
sys.exit(WARNING)
elif status == CRITICAL:
print "%sCRITICAL: %s | %s" % (check, message, perfdata)
sys.exit(CRITICAL)
else:
print "UNKNOWN: %s" % message
sys.exit(UNKNOWN)