mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 10:23:46 +01:00
check_yum modified to support rhel6
This commit is contained in:
parent
be3d09b7e1
commit
8f4a5f499f
@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
__author__ = "Hari Sekhon"
|
__author__ = "Hari Sekhon"
|
||||||
__title__ = "Nagios Plugin for Yum updates on RedHat/CentOS systems"
|
__title__ = "Nagios Plugin for Yum updates on RedHat/CentOS systems"
|
||||||
__version__ = "0.7.1"
|
__version__ = "0.7.2"
|
||||||
|
|
||||||
|
# Changes:
|
||||||
|
# 0.7.2 added support for rhel6-style yum output
|
||||||
|
|
||||||
|
|
||||||
# Standard Nagios return codes
|
# Standard Nagios return codes
|
||||||
OK = 0
|
OK = 0
|
||||||
@ -29,19 +33,19 @@ from optparse import OptionParser
|
|||||||
DEFAULT_TIMEOUT = 30
|
DEFAULT_TIMEOUT = 30
|
||||||
|
|
||||||
|
|
||||||
def end(status, message):
|
def end(status, message, perfdata=''):
|
||||||
"""Exits the plugin with first arg as the return code and the second
|
"""Exits the plugin with first arg as the return code and the second
|
||||||
arg as the message to output"""
|
arg as the message to output"""
|
||||||
|
|
||||||
check = "YUM "
|
check = "YUM "
|
||||||
if status == OK:
|
if status == OK:
|
||||||
print "%sOK: %s" % (check, message)
|
print "%sOK: %s | %s" % (check, message, perfdata)
|
||||||
sys.exit(OK)
|
sys.exit(OK)
|
||||||
elif status == WARNING:
|
elif status == WARNING:
|
||||||
print "%sWARNING: %s" % (check, message)
|
print "%sWARNING: %s | %s" % (check, message, perfdata)
|
||||||
sys.exit(WARNING)
|
sys.exit(WARNING)
|
||||||
elif status == CRITICAL:
|
elif status == CRITICAL:
|
||||||
print "%sCRITICAL: %s" % (check, message)
|
print "%sCRITICAL: %s | %s" % (check, message, perfdata)
|
||||||
sys.exit(CRITICAL)
|
sys.exit(CRITICAL)
|
||||||
else:
|
else:
|
||||||
print "UNKNOWN: %s" % message
|
print "UNKNOWN: %s" % message
|
||||||
@ -317,22 +321,32 @@ class YumTester:
|
|||||||
|
|
||||||
output = self.run(cmd)
|
output = self.run(cmd)
|
||||||
|
|
||||||
re_security_summary = \
|
re_security_summary_rhel5 = re.compile("Needed \d+ of \d+ packages, for security")
|
||||||
re.compile("Needed \d+ of \d+ packages, for security")
|
re_security_summary_rhel6 = re.compile("\d+ package\(s\) needed for security, out of \d+ available")
|
||||||
re_no_security_updates_available = \
|
re_no_security_updates_available_rhel5 = re.compile("No packages needed, for security, \d+ available")
|
||||||
re.compile("No packages needed, for security, \d+ available")
|
re_no_security_updates_available_rhel6 = re.compile("No packages needed for security; \d+ packages available")
|
||||||
summary_line_found = False
|
summary_line_found = False
|
||||||
for line in output:
|
for line in output:
|
||||||
if re_no_security_updates_available.match(line):
|
if re_no_security_updates_available_rhel5.match(line):
|
||||||
summary_line_found = True
|
summary_line_found = True
|
||||||
number_security_updates = 0
|
number_security_updates = 0
|
||||||
number_total_updates = line.split()[5]
|
number_total_updates = line.split()[5]
|
||||||
break
|
break
|
||||||
elif re_security_summary.match(line):
|
if re_no_security_updates_available_rhel6.match(line):
|
||||||
|
summary_line_found = True
|
||||||
|
number_security_updates = 0
|
||||||
|
number_total_updates = line.split()[5]
|
||||||
|
break
|
||||||
|
if re_security_summary_rhel5.match(line):
|
||||||
summary_line_found = True
|
summary_line_found = True
|
||||||
number_security_updates = line.split()[1]
|
number_security_updates = line.split()[1]
|
||||||
number_total_updates = line.split()[3]
|
number_total_updates = line.split()[3]
|
||||||
break
|
break
|
||||||
|
if re_security_summary_rhel6.match(line):
|
||||||
|
summary_line_found = True
|
||||||
|
number_security_updates = line.split()[0]
|
||||||
|
number_total_updates = line.split()[7]
|
||||||
|
break
|
||||||
|
|
||||||
if not summary_line_found:
|
if not summary_line_found:
|
||||||
end(WARNING, "Cannot find summary line in yum output. Please " \
|
end(WARNING, "Cannot find summary line in yum output. Please " \
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Summary: Nagios plugin to test for Yum updates on RedHat/CentOS Linux.
|
Summary: Nagios plugin to test for Yum updates on RedHat/CentOS Linux.
|
||||||
Name: nagios-okplugin-check_yum
|
Name: nagios-okplugin-check_yum
|
||||||
Version: 0.7.1
|
Version: 0.7.1
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://opensource.is/trac/wiki/check_yum
|
URL: http://opensource.is/trac/wiki/check_yum
|
||||||
|
Loading…
Reference in New Issue
Block a user