Hello community,

here is the log from the commit of package nagios-plugins-nfsmounts for 
openSUSE:Factory checked in at 2013-01-25 09:35:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nagios-plugins-nfsmounts (Old)
 and      /work/SRC/openSUSE:Factory/.nagios-plugins-nfsmounts.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nagios-plugins-nfsmounts", Maintainer is ""

Changes:
--------
New Changes file:

--- /dev/null   2013-01-09 19:40:42.352580873 +0100
+++ 
/work/SRC/openSUSE:Factory/.nagios-plugins-nfsmounts.new/nagios-plugins-nfsmounts.changes
   2013-01-25 09:35:04.000000000 +0100
@@ -0,0 +1,17 @@
+-------------------------------------------------------------------
+Wed Jul  4 09:30:53 UTC 2012 - [email protected]
+
+- specfile cleanup
+- require nagios-plugins-common instead of nagios-plugins
+
+-------------------------------------------------------------------
+Wed Dec 14 11:40:09 UTC 2011 - [email protected]
+
+- get rid of licenses package dependency
+- use nagios-rpm-macros
+
+-------------------------------------------------------------------
+Mon May 25 10:48:09 CEST 2009 - [email protected]
+
+- initial version 1.0
+

New:
----
  GPLv3
  check_nfsmounts
  nagios-plugins-nfsmounts.changes
  nagios-plugins-nfsmounts.spec

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nagios-plugins-nfsmounts.spec ++++++
#
# spec file for package nagios-plugins-nfsmounts
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

Name:           nagios-plugins-nfsmounts
Version:        1.0
Release:        1
License:        GPL-3.0+
Summary:        Checks all local NFS mounts
Url:            
https://www.monitoringexchange.org/inventory/Check-Plugins/Operating-Systems/Linux/check_nfsmounts
Group:          System/Monitoring
Source0:        check_nfsmounts
Source1:        GPLv3
%if 0%{?suse_version} > 1010
# nagios can execute the script with embedded perl
Recommends:     perl
%endif
BuildRequires:  nagios-rpm-macros
Requires:       nagios-plugins-common
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

%description
A perl script that checks all local NFS mounts by forking itself and trying to
chdir to it and (optionally) writing to a file. It includes performance data
and allows warnings based on thresholds.

%prep

%build

%install
install -D -m755 %{SOURCE0} %{buildroot}/%{nagios_plugindir}/check_nfsmounts
install -D -m644 %{SOURCE1} %{buildroot}/%{_defaultdocdir}/%{name}/COPYING

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name}
# avoid build dependecy of nagios - own the dirs
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%{nagios_plugindir}/check_nfsmounts

%changelog
++++++ GPLv3 ++++++
++++ 674 lines (skipped)

++++++ check_nfsmounts ++++++
#!/usr/bin/perl
# vim: ts=2 sts=2 sw=2:et ai:
#
# Usage: check_nfsmounts [ -t nfs timeout ] [ -w ]
# Description: determines whether there are stale NFS mounts on the host.
# Author: Clint Byrum <[email protected]>
#
#    Copyright 2007 Adicio, Inc.
#
#    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 3 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, see <http://www.gnu.org/licenses/>. 
#

use lib "/usr/lib/nagios/plugins" ;
use utils qw{$TIMEOUT %ERRORS};
use Time::HiRes qw{time alarm};
use Getopt::Long;
use strict;

my $version="1.0";

my $nfs_timeout=$TIMEOUT;
my $nfs_warn=-1;
my $writemode=0;
my $help=0;

sub usage {
  print STDERR "NFS UNKNOWN: version $version, check_nfs_client [ 
--nfs-critical|-c seconds ]\n";
  print STDERR "             [ --nfs-warning seconds ][ --writemode|-w ]\n";
  exit $ERRORS{'UNKNOWN'};
}

if(!GetOptions('nfs-timeout|nfstimeout|critical|c|t=f' => \$nfs_timeout,
               'nfs-warning=f' => \$nfs_warn,
               'writemode|write|w' => \$writemode,
               'help' => \$help,
          )) {
  &usage;
}

if($help) {
  &usage;
}

if($nfs_timeout <= 0) {
  print STDERR "timeout must be greater than 0\n";
  &usage;
}

our $dir; # Because its a signal handler, we have to 
sub alarm_handler {
  print "NFS CRITICAL:  Stale NFS mount point - $dir.\n";
  exit $ERRORS{'CRITICAL'};
}

sub bad_mount {
  my $mountpoint=shift();
  my $emsg=shift();
  print "NFS CRITICAL: cannot operate on mount point $mountpoint. [$emsg]\n";
  exit $ERRORS{'CRITICAL'};
}

#my @dirs = `mount | grep " type nfs " | awk '{print \$3}'`;
if(!open MTAB,"< /etc/mtab") {
  print "NFS UNKNOWN: could not open mtab.\n";
  exit $ERRORS{'UNKNOWN'};
}

my @dirs=();
my %mountmodes=();
while(my $line=<MTAB>) {
  if($line =~ /^[^ ]+ [^ ]+ nfs /) {
    my @fields=split(/\s+/,$line);
    my $mountpoint=$fields[1];
    push(@dirs,$mountpoint);
    #my %modes=split(/,/,$fields[3]);
    my $modes = {};
    foreach my $mode (split(/,/,$fields[3])) {
      $modes->{$mode}=1;
    }
    $mountmodes{$mountpoint}=$modes;
  }
}
close MTAB;

if(@dirs < 1) {
  print "NFS OK: no NFS mounts found.\n";
  exit $ERRORS{'OK'};
}

my @ages=();
my @warnings=();
foreach $dir (@dirs) {
  chomp $dir;
  $SIG{ALRM} = \&alarm_handler;
  my $start=time;
  my $pid=fork;
  if($pid==0) {
    chdir $dir or &bad_mount($dir,$!);
    if($writemode and exists($mountmodes{$dir}->{"rw"})) {
      open X,"> $dir/.nfscheck" or exit $?;
      print X $ENV{HOSTNAME}."\n".localtime()."\n"; # XXX Full disk may fail..
      close X or exit $?;
    }
    exit 0;
  } else {
    alarm $nfs_timeout;
    waitpid $pid,0;
    if($?) {
      &bad_mount($dir,$?);
    };
    alarm 0;
  }
  my $age=time()-$start;
  if($nfs_warn > 0 and $age > $nfs_warn) {
    push(@warnings,sprintf("$dir took %7.5f to complete all operations ",$age));
  }
  push(@ages,$age);
}

my $x=0;
my $agetot=0;
my $maxage=0;
foreach my $age (@ages) {
  $agetot+=$age;
  if($age > $maxage) {
    $maxage=$age;
  }
  $x++;
}
my $avgage=$agetot/$x;

my 
$perfdata=sprintf("maxtime=%9.7f;avgtime=%9.7f;mountpoints=$x",$maxage,$avgage);

if(@warnings) {
  print "NFS WARNING: @warnings|$perfdata\n";
  exit $ERRORS{'WARNING'};
}
  
printf "NFS OK: $x mount points avg of %7.5f secs, max %7.5f 
secs.|$perfdata\n",$avgage,$maxage,$maxage,$avgage;
exit $ERRORS{'OK'};
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to