@@ -85,8 +85,8 @@
0 => 'OK',
);
our %supported_release = (
- 'openSUSE' => [ '11.4', '12.1', '12.2' ],
- 'SLE' => [ '10.4', '11.1', '11.2' ],
+ 'openSUSE' => [ '11.4', '12.1', '12.2', '12.3' ],
+ 'SLE' => [ '10.4', '11.1', '11.2', '11.3' ],
);
$opt_w = 'recommended,optional,unsupported';
$opt_c = 'security';
|
@@ -0,0 +1,553 @@
+#!/usr/bin/perl -w
+# nagios: -epn
+#
+# check_zypper - nagios plugin
+#
+# Copyright (C) 2008-2009, Novell, Inc.
+# Author: Lars Vogdt
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# * Neither the name of the Novell nor the names of its contributors may be
+# used to endorse or promote products derived from this software without
+# specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# $Id$
+#
+
+use strict;
+use warnings;
+use Getopt::Long;
+use vars qw($PROGNAME $VERSION $DEBUG);
+
+# cleanup the environment
+$ENV{'PATH'} = '/bin:/usr/bin:/sbin:/usr/sbin:';
+$ENV{'BASH_ENV'} = '';
+$ENV{'ENV'} = '';
+
+# constants
+$PROGNAME = "check_zypper";
+$VERSION = "1.26";
+$DEBUG = 0;
+
+# variables
+our $zypper = "/usr/bin/zypper";
+our $zypperopt = "--non-interactive --no-gpg-checks xml-updates";
+our $sudo = "/usr/bin/sudo";
+our $refresh_wrapper = "/usr/sbin/zypp-refresh-wrapper";
+our $use_sudo = "unset LANG; ";
+our $releasefile = "/etc/SuSE-release";
+our $release = "11.2";
+our $dist = "openSUSE";
+our $patchlevel = 0;
+our ( $opt_V, $opt_h, $opt_i, $opt_w, $opt_c, $opt_f, $opt_o, $opt_p, $opt_r, $opt_s, $opt_t, $opt_v );
+our $exitcode = 0;
+our %ERRORS = ( 'OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4 );
+our %REVERSE = ( 4 => 'DEPENDENT', 3 => 'UNKNOWN', 2 => 'CRITICAL', 1 => 'WARNING', 0 => 'OK' );
+our $TIMEOUT = 120;
+our @patchignore = ();
+our @packageignore = ();
+
+$opt_w = "recommended,optional";
+$opt_c = "security";
+$opt_f = "$releasefile";
+$opt_t = "120";
+$opt_v = 0;
+$opt_o = 0;
+$opt_p = 1;
+$opt_s = 0;
+
+#######################################################################
+# Functions
+#######################################################################
+
+sub print_myrevision ($$) {
+ my $commandName = shift;
+ my $pluginRevision = shift;
+ print "$commandName v$pluginRevision\n";
+}
+
+sub mysupport () {
+ print "Please use https://bugzilla.novell.com to submit patches or suggest improvements.\n";
+ print "Please include version information with all correspondence (when possible,\n";
+ print "use output from the --version option of the plugin itself).\n";
+}
+
+sub usage ($) {
+ my $format = shift;
+ printf( $format, @_ );
+ exit $ERRORS{'UNKNOWN'};
+}
+
+sub get_distribution($) {
+ my $file = shift || "$releasefile";
+ open( RELEASE, "<$file" ) || warn("Could not open $file\n");
+ while (<RELEASE>) {
+ if (/^SUSE Linux Enterprise/) {
+ $dist = "SLE";
+ }
+ if (/^VERSION/) {
+ ($release) = $_ =~ m/VERSION = (.*)/;
+ }
+ if (/^PATCHLEVEL/) {
+ ($patchlevel) = $_ =~ m/PATCHLEVEL = (.*)/;
+ }
+ }
+ close(RELEASE);
+ return ( $dist, $release, $patchlevel );
+}
+
+sub print_usage () {
+ print "This plugin checks for software updates on systems that use package\n";
+ print "management systems based on the zypper command found in openSUSE.\n\n";
+ print "It checks for security, recommended and optional patches and also for\n";
+ print "optional package updates.\n\n";
+ print "You can define the status by patch category. Use a commata to list more\n";
+ print "than one category to a state. Possible values are recommended,optional,security\n";
+ print "and packages\n\n";
+ print "If you like to know the names of available patches and packages, use\n";
+ print "the \"-v\" option.\n\n";
+ print "Usage:\n";
+ print " $PROGNAME [-w <category>] [-c <category>] [-t <timeout>] [-v]\n";
+ print " $PROGNAME [-h | --help]\n";
+ print " $PROGNAME [-V | --version]\n";
+ print "\n\nOptions:\n";
+ print " -c, --critical\n";
+ print " A patch with this category result in critical status.\n";
+ print " Default: $opt_c\n";
+ print " -f, --releasefile\n";
+ print " Use the given file to get informations about the distribution.\n";
+ print " Default: $releasefile\n";
+ print " -h, --help\n";
+ print " Print detailed help screen\n";
+ print " -i, --ignore <file>\n";
+ print " Ignore patches/packages that are mentioned in <file>\n";
+ print " Just list one patch/package per line - example:\n\n";
+ print " patch:libtiff-devel\n";
+ print " # comment\n";
+ print " package:libtiff3\n";
+ print " package:libtiff-devel\n\n";
+ print " -o, --ignore_outdated\n";
+ print " Don't warn if a repository is outdated.\n";
+ print " -p, --no_perfdata\n";
+ print " Print no perfdata\n";
+ print " -r, --refresh_repos\n";
+ print " Tries to refresh the repositories before checking for updates.\n";
+ print " Note: this maybe needs an entry in /etc/sudoers like:\n";
+ print " nagios ALL = NOPASSWD: /usr/bin/zypper ref\n";
+ print " (and additional lines for the \'-s\' Option) if no check-zypp-wrapper is available.\n";
+ print " -s, --use_sudo\n";
+ print " Zypper needs root privileges on some distributions (known: 10.1 and SLE10).\n";
+ print " You can enable the script to use $sudo to start zypper.\n";
+ print " But don't forget to enable nopasswd sudo for the user starting $PROGNAME\n";
+ print " Via lines like the two below on in /etc/sudoers:\n";
+ print " nagios ALL = NOPASSWD: /usr/bin/zypper sl, \\ \n";
+ print " /usr/bin/zypper $zypperopt\n";
+ print " -t, --timeout\n";
+ print " Just in case of problems, let's not hang Nagios and define a timeout.\n";
+ print " Default value is: $opt_t seconds\n";
+ print " -v, --verbose_output\n";
+ print " Print more information (useful only with Nagios v3.x).\n";
+ print " -w, --warning\n";
+ print " A patch with this category result in warning status.\n";
+ print " Default: $opt_w\n";
+ print "\n";
+ print " -V, --version\n";
+ print " Print version information\n";
+ print "\n";
+ print " -d, --debug\n";
+ print " Print debug output to STDERR\n";
+}
+
+sub print_help {
+ my $exit = shift || undef;
+ print "Copyright (c) 2009, Novell, Inc.\n\n";
+ print_usage();
+ print "\n";
+ mysupport();
+ exit $exit if ( defined($exit) );
+}
+
+sub check_zypper() {
+ if ( -x "$zypper" ) {
+ print STDERR "INFO: Trying $use_sudo $zypper sl 2>/dev/null 1>&2\n" if ($DEBUG);
+ return ( system("$use_sudo $zypper sl 2>/dev/null 1>&2") );
+ }
+ else {
+ return 1;
|