|
@@ -1,21 +1,4 @@
#!/usr/bin/env python
-#
-# Copyright Hari Sekhon 2008
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
"""Nagios plugin to test for Yum updates on RedHat/CentOS Linux.
Can optionally alert on any available updates as well as just
@@ -23,7 +6,7 @@
__author__ = "Hari Sekhon"
__title__ = "Nagios Plugin for Yum updates on RedHat/CentOS systems"
-__version__ = "0.6.9"
+__version__ = "0.7.1"
# Standard Nagios return codes
OK = 0
@@ -275,6 +258,7 @@
print "\nSection:\n%s\n" % section
if len(output2) > 2 or \
not ( "Setting up repositories" in output2[0] or \
+ "Loaded plugins: " in output2[0] or \
re.search('Loading\s+".+"\s+plugin', output2[0]) ):
end(WARNING, "Yum output signature does not match current known " \
+ "format. Please make sure you have upgraded to the " \
@@ -286,7 +270,7 @@
number_packages = 0
else:
number_packages = len([x for x in output2[1].split("\n") \
- if x != "" ])
+ if len(x.split()) > 1 ])
try:
number_packages = int(number_packages)
@@ -305,6 +289,12 @@
count = 0
re_package_format = \
re.compile("^.+\.(i[3456]86|x86_64|noarch)\s+.+\s+.+$")
+ # This is to work around a yum truncation issue effectively changing
+ # the package output format. Currently only very long kmod lines
+ # are seen to have caused this so we stick to what we know for safety
+ # and raise an unknown error on anything else for maximum security
+ #re_package_format_truncated = \
+ # re.compile("^[\w-]+-kmod-\d[\d\.-]+.*\s+.+\s+.+$")
for line in output:
if re_package_format.match(line):
count += 1
|