Changes of Revision 4
[+] | Deleted | nagios-plugins-zypper.changes |
@@ -1,21 +0,0 @@ -------------------------------------------------------------------- -Mon Jul 28 15:34:18 CEST 2008 - lrupp@suse.de - -- ignore error messages: they bother the nagios parser - -------------------------------------------------------------------- -Tue May 6 13:14:59 CEST 2008 - lars@linux-schulserver.de - -- ignore host variable for now: this check only works local - -------------------------------------------------------------------- -Tue Apr 15 16:10:39 CEST 2008 - lrupp@suse.de - -- work also with 10.2 and SLES10-SP1 -- accept arguments -w and -c - -------------------------------------------------------------------- -Mon Apr 14 20:06:20 CEST 2008 - lrupp@suse.de - -- initial version 0.1 - | ||
[-] | Changed | nagios-plugins-zypper.spec ^ |
x 1
2 # 3 -# spec file for package nagios-plugins-zypper 4 +# spec file for package nagios-plugins-zypper (Version 0.911) 5 # 6 -# This file and all modifications and additions to the pristine 7 -# package are under the same license as the package itself. 8 +# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. 9 +# 10 +# All modifications and additions to the file contributed by third parties 11 +# remain the property of their copyright owners, unless otherwise agreed 12 +# upon. The license for this file, and modifications and additions to the 13 +# file, is the same license as for the pristine package itself (unless the 14 +# license for the pristine package is not an Open Source License, in which 15 +# case the license is the MIT License). An "Open Source License" is a 16 +# license that conforms to the Open Source Definition (Version 1.9) 17 +# published by the Open Source Initiative. 18 + 19 +# Please submit bugfixes or comments via http://bugs.opensuse.org/ 20 # 21 22 # norootforbuild 23 24 + 25 Name: nagios-plugins-zypper 26 Summary: Nagios plugin for checking software updates 27 -Version: 0.1 28 -Release: 1 29 -Url: http://en.opensuse.org/nagios-plugins-zypper 30 -License: GPL v2 only 31 +Version: 0.980 32 +Release: 1.2 33 +Url: http://en.opensuse.org/Nagios-plugins-zypper 34 +License: BSD 4-Clause 35 Group: System/Monitoring 36 Source0: check_zypper.pl 37 %if 0%{?suse_version} > 1010 38
39 Requires: zypper 40 BuildArch: noarch 41 BuildRoot: %{_tmppath}/%{name}-%{version}-build 42 -%define libexecdir %_prefix/lib/nagios/plugins 43 +%define libexecdir %_prefix/lib/nagios/plugins 44 45 %description 46 -This plugin checks for software updates on systems that use 47 -package management systems based on the libzypp command 48 -found in openSUSE 49 +This plugin checks for software updates on systems that use package 50 +management systems based on the zypper command found in openSUSE. 51 + 52 +It checks for security, recommended and optional patches and also for 53 +optional package updates. 54 + 55 +You can define the status by patch category. Use a commata to list more 56 +than one category to a state. 57 + 58 +If you like to know the names of available patches and packages, use 59 +the "-v" option. 60 + 61 + 62 63 Authors: 64 -------- 65 Lars Vogdt 66 67 - 68 %prep 69 70 %build 71 72 %install 73 -install -D -m755 %{SOURCE0} %buildroot/%libexecdir/check_zypper.pl 74 +install -D -m755 %{SOURCE0} %buildroot/%libexecdir/check_zypper 75 76 %clean 77 rm -rf %buildroot 78
79 # avoid build dependecy of nagios - own the dirs 80 %dir %_prefix/lib/nagios 81 %dir %libexecdir 82 -%libexecdir/check_zypper.pl 83 +%libexecdir/check_zypper 84 85 %changelog 86 +* Fri Feb 20 2009 lars@linux-schulserver.de 87 +- update to 0.980: 88 + + also support old Nagios v2 output format 89 + + no whitespaces in perfdata output 90 +* Mon Feb 16 2009 lrupp@suse.de 91 +- update to 0.975: 92 + + added option '-i' to allow admins to ignore some patches/ 93 + packages via config file 94 +* Thu Feb 12 2009 lrupp@suse.de 95 +- update to 0.966: 96 + + support nagios embedded perl interpreter 97 +* Wed Jan 28 2009 lrupp@suse.de 98 +- update to 0.965: 99 + + added option '-r' to refresh zypper automatically 100 +* Wed Jan 28 2009 lrupp@suse.de 101 +- update to 0.951: 102 + - return perfdata even if no update is available 103 +* Tue Jan 27 2009 lrupp@suse.de 104 +- update to 0.950: 105 + - allow to ignore outdated repositories with -o 106 + - reset alarm() on exit 107 + - handle unknown options instead of ignoring them 108 + - first version of performancedata output in check result 109 +* Tue Dec 16 2008 lrupp@suse.de 110 +- update to 0.911: 111 + + first working version for 11.1 112 + + use own functions: nagios-plugins is obsolete 113 + + better exit handling for -c and -w options 114 + + warn, if a repository is out of date 115 + + small enhancements for -v option 116 +* Thu Nov 27 2008 lrupp@suse.de 117 +- update to 0.9: 118 + - better whitespace handling for SLE10 based products 119 +* Thu Oct 23 2008 lrupp@suse.de 120 +- update to 0.8.1: 121 + + enhance the documentation (help text) 122 +* Wed Oct 22 2008 lrupp@suse.de 123 +- update to 0.8: 124 + + return UNKNOWN if zypper prints "Error message" 125 + + return UNKNOWN if zypper is already running 126 +* Mon Sep 29 2008 lrupp@suse.de 127 +- update to 0.7: 128 + + enable verbose output for SLE10 based hosts 129 +* Wed Sep 17 2008 lrupp@suse.de 130 +- update to 0.6: 131 + + added error handling if update source is not available 132 + + switch to BSD License 133 +* Thu Sep 11 2008 lrupp@suse.de 134 +- fix stupid variable clash 135 +* Wed Sep 10 2008 lrupp@suse.de 136 +- update to 0.5: 137 + + code cleanup 138 + + return UNKNOWN state if system doesn't support check without 139 + sudo rights 140 + + allow user to specify the release file with '-r' 141 +* Wed Sep 3 2008 lrupp@suse.de 142 +- update to 0.4: 143 + + added sudo option to call zypper via sudo 144 + + don't print packagelist if packagelist is empty 145 +* Tue Sep 2 2008 lrupp@suse.de 146 +- update to 0.3: 147 + + now outputs also the names of patches and packages, if selected 148 + + improved help output 149 +- truncate the trailing .pl so the script follows the nagios 150 + plugins scheme 151 +* Mon Jul 28 2008 lrupp@suse.de 152 +- ignore error messages: they bother the nagios parser 153 +* Tue May 6 2008 lrupp@suse.de 154 +- ignore host variable for now: this check only works local 155 +* Tue Apr 15 2008 lrupp@suse.de 156 +- work also with 10.2 and (not tested:) SLES10-SP1 157 +- accept arguments -w and -c 158 +* Mon Apr 14 2008 lrupp@suse.de 159 +- initial version 0.1 160 |
||
[+] | Changed | check_zypper.pl ^ |
@@ -1,163 +1,228 @@ #!/usr/bin/perl -w +# nagios: -epn # -# check_zypper.pl - nagios plugin +# check_zypper - nagios plugin # -# Copyright (C) 2008 Lars Vogdt, +# Copyright (C) 2008, Novell, Inc. +# Author: Lars Vogdt # -# 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; version 2 -# of the License. +# All rights reserved. # -# 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. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: # -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# * 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. # -# Report bugs to: nagiosplug-help@lists.sourceforge.net +# * 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. # -# 14.04.2008 Version 0.1 -# 15.04.2008 Version 0.2 -# TOOD: "online_update --dry-run --no-sig-check --check" for SLES9 +# 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); -use lib "/usr/lib/nagios/plugins"; # Pfad to util.pm -use utils qw ($TIMEOUT %ERRORS &print_revision &support &usage); - -sub print_help (); -sub print_usage (); -sub check(); +use vars qw($PROGNAME $VERSION $DEBUG); +# cleanup the environment $ENV{'PATH'}='/bin:/usr/bin:/sbin:/usr/sbin:'; $ENV{'BASH_ENV'}=''; $ENV{'ENV'}=''; -my ($opt_V, $opt_h, $opt_H, $opt_w, $opt_c, $opt_t); -my $DEBUG = 0; - +# constants $PROGNAME="check_zypper"; +$VERSION="0.98ß"; +$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.0"; +our $dist="openSUSE"; +our $patchlevel=0; +our ($opt_V, $opt_h, $opt_i, $opt_H, $opt_w, $opt_c, $opt_f, $opt_o, $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_H=""; $opt_w="recommended,optional"; $opt_c="security"; +$opt_f="$releasefile"; $opt_t="120"; - -my $zypper="/usr/bin/zypper"; -my $zypperopt="--non-interactive --no-gpg-checks xml-updates"; -my $release="10.3"; -my $dist="openSUSE"; -my $patchlevel=0; - -open(RELEASE,"</etc/SuSE-release"); -while (<RELEASE>){ - if (/^SUSE Linux Enterprise/){ - $dist="SLE"; - } - if (/^VERSION/){ - ( $release ) = $_ =~ m/VERSION = (.*)/; - } - if (/^PATCHLEVEL/){ - ( $patchlevel ) = $_ =~ m/PATCHLEVEL = (.*)/; +$opt_v=0; +$opt_o=0; +$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); - -if ("$release" eq "10.2"){ - $zypperopt="--non-interactive --no-gpg-checks list-updates"; -} - -if ("$dist" eq "SLE"){ - if (("$release" eq "10") && ($patchlevel gt 0)){ - $zypperopt="--non-interactive list-updates"; - } else { - print "UNKNOWN - SLE $release is currently not supported\n"; - exit $ERRORS{"UNKNOWN"}; - } -} - -Getopt::Long::Configure('bundling'); -GetOptions( - "V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "H=s" => \$opt_H, "hostname" => \$opt_H, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "t=i" => \$opt_t, "timeout=i" => \$opt_t); - -if ($opt_t) { - $TIMEOUT=$opt_t; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print "UNKNOWN - Plugin timed out\n"; - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - -if ($opt_V) { |