Hello community,
here is the log from the commit of package nagios-plugins-zypper
checked in at Wed Sep 24 17:13:57 CEST 2008.
--------
--- nagios-plugins-zypper/nagios-plugins-zypper.changes 2008-09-10 11:52:04.000000000 +0200
+++ /mounts/work_src_done/STABLE/nagios-plugins-zypper/nagios-plugins-zypper.changes 2008-09-17 12:27:00.000000000 +0200
@@ -1,0 +2,12 @@
+Wed Sep 17 12:26:17 CEST 2008 - lrupp@suse.de
+
+- update to 0.6:
+ + added error handling if update source is not available
+ + switch to BSD License
+
+-------------------------------------------------------------------
+Thu Sep 11 15:41:55 CEST 2008 - lrupp@suse.de
+
+- fix stupid variable clash
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ nagios-plugins-zypper.spec ++++++
--- /var/tmp/diff_new_pack.Gz7345/_old 2008-09-24 17:13:49.000000000 +0200
+++ /var/tmp/diff_new_pack.Gz7345/_new 2008-09-24 17:13:49.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package nagios-plugins-zypper (Version 0.5)
+# spec file for package nagios-plugins-zypper (Version 0.6)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -20,10 +20,10 @@
Name: nagios-plugins-zypper
Summary: Nagios plugin for checking software updates
-Version: 0.5
+Version: 0.6
Release: 1
Url: http://en.opensuse.org/nagios-plugins-zypper
-License: GPL v2 only
+License: BSD 4-Clause
Group: System/Monitoring
Source0: check_zypper.pl
%if 0%{?suse_version} > 1010
@@ -74,6 +74,12 @@
%libexecdir/check_zypper
%changelog
+* Wed Sep 17 2008 lrupp@suse.de
+- update to 0.6:
+ + added error handling if update source is not available
+ + switch to BSD License
+* Thu Sep 11 2008 lrupp@suse.de
+- fix stupid variable clash
* Wed Sep 10 2008 lrupp@suse.de
- update to 0.5:
+ code cleanup
++++++ check_zypper.pl ++++++
--- nagios-plugins-zypper/check_zypper.pl 2008-09-10 11:49:38.000000000 +0200
+++ /mounts/work_src_done/STABLE/nagios-plugins-zypper/check_zypper.pl 2008-09-17 13:30:12.000000000 +0200
@@ -1,56 +1,65 @@
#!/usr/bin/perl -w
#
-# 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
-# 02.09.2008 Version 0.3
-# 04.09.2008 Version 0.4
-# 10.09.2008 Version 0.5
+# 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.
#
-# TOOD: "online_update --dry-run --no-sig-check --check" for SLES9
+# $Id$
#
use strict;
use Getopt::Long;
use vars qw($PROGNAME);
-use lib "/usr/lib/nagios/plugins"; # Pfad to util.pm
+use lib "/usr/lib/nagios/plugins"; # Path to util.pm
use utils qw ($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
sub print_usage ();
+# cleanup the environment
$ENV{'PATH'}='/bin:/usr/bin:/sbin:/usr/sbin:';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
+# constants
$PROGNAME="check_zypper";
-my $VERSION=0.5;
+my $VERSION="0.6";
my $DEBUG = 0;
+# variables
my $zypper="/usr/bin/zypper";
my $zypperopt="--non-interactive --no-gpg-checks xml-updates";
my $sudo="/usr/bin/sudo";
-my $use_sudo="";
+my $use_sudo="unset LANG; ";
my $releasefile="/etc/SuSE-release";
my $release="11.0";
my $dist="openSUSE";
@@ -71,9 +80,6 @@
sub get_distribution($){
my $file=shift || "$releasefile";
- my $release="11.0";
- my $dist="openSUSE";
- my $patchlevel=0;
open(RELEASE,"<$file") || warn ("Could not open $file\n");
while (<RELEASE>){
if (/^SUSE Linux Enterprise/){
@@ -91,10 +97,14 @@
}
sub print_usage () {
- print "This plugin checks for software updates on systems that use\npackage management systems based on the libzypp library\nfound in openSUSE.\n\n";
- print "It checks for security, recommended and optional patches and also for optional package updates.\n\n";
- print "You can define the status by patch category. Use a commata to list more than one category to a state.\n\n";
- print "If you like to know the names of available patches and packages, use the \"-v\" option.\n\n";
+ 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.\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";
@@ -114,7 +124,7 @@
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 a line like this on in /etc/sudoers:\n";
- print " nagios ALL = NOPASSWD: /usr/bin/zypper\n";
+ print " nagios ALL = NOPASSWD: /usr/bin/zypper\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";
@@ -128,7 +138,7 @@
}
sub print_help () {
- print "Copyright (c) 2008 Lars Vogdt\n\n";
+ print "Copyright (c) 2008, Novell, Inc.\n\n";
print_usage();
print "\n";
print " <help> This output\n";
@@ -137,10 +147,12 @@
}
sub check_zypper(){
- if ( -x $zypper ){
+ if ( -x "$zypper" ){
+ print STDERR "Trying: $use_sudo $zypper sl 2>/dev/null 1>&2\n" if ( $DEBUG );
return (system("$use_sudo $zypper sl 2>/dev/null 1>&2"));
- }
- return 1;
+ } else {
+ return 1;
+ }
}
sub check_errorcode($){
@@ -164,97 +176,95 @@
my %packagelist;
$error="UNKNOWN";
$ret_str="$error - Unknown state\n";
- if ( -x "$zypper" ){
- $use_sudo="$sudo" if ($opt_s);
- if (open (FH, "$use_sudo $zypper $zypperopt |")) {
- while(<FH>){
- chomp;
- my $category="unknown";
- print "LINE: $_\n" if ($DEBUG);
- if (( "$release" eq "10.2" ) || ("$dist" eq "SLE")){
- $optcount++ if (/\| optional \| Needed/);
- $reccount++ if (/\| recommended \| Needed/);
- $seccount++ if (/\| security \| Needed/);
- } else {
- if (/