[Pkg-nagios-changes] nagios-plugins/debian/patches 10_config.h_debiandefaults.dpatch, 1.3, 1.4 22_check_smb_hostaddress.dpatch, NONE, 1.1

seanius at haydn.debian.org seanius at haydn.debian.org
Mon Oct 31 21:35:54 UTC 2005


Update of /cvsroot/pkg-nagios/nagios-plugins/debian/patches
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv715/debian/patches

Modified Files:
	10_config.h_debiandefaults.dpatch 
Added Files:
	22_check_smb_hostaddress.dpatch 
Log Message:
fix for the ftbfs, and some other stuff


Index: 10_config.h_debiandefaults.dpatch
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios-plugins/debian/patches/10_config.h_debiandefaults.dpatch,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- 10_config.h_debiandefaults.dpatch	6 Oct 2005 09:19:36 -0000	1.3
+++ 10_config.h_debiandefaults.dpatch	31 Oct 2005 21:35:50 -0000	1.4
@@ -5,19 +5,9 @@
 ## DP: No description.
 
 @DPATCH@
-diff -urNad sid~/config.h.in sid/config.h.in
---- sid~/config.h.in	2005-10-03 02:50:20.000000000 -0400
-+++ sid/config.h.in	2005-10-06 04:33:15.000000000 -0400
-@@ -854,3 +854,6 @@
- /* Define to unsigned long or unsigned long long if <inttypes.h> and
-    <stdint.h> don't define. */
- #undef uintmax_t
-+
-+/* include debian-specific hardcoded values */
-+#include "np-debian.h"
 diff -urNad sid~/configure sid/configure
---- sid~/configure	2005-10-03 02:59:07.000000000 -0400
-+++ sid/configure	2005-10-06 04:33:15.000000000 -0400
+--- sid~/configure	2005-09-30 15:56:02.000000000 +0200
++++ sid/configure	2005-10-31 21:15:42.000000000 +0100
 @@ -7760,7 +7760,7 @@
  fi;
  
@@ -28,8 +18,8 @@
  LDFLAGS="$LDFLAGS -L."
  
 diff -urNad sid~/np-debian.h sid/np-debian.h
---- sid~/np-debian.h	1969-12-31 19:00:00.000000000 -0500
-+++ sid/np-debian.h	2005-10-06 04:33:15.000000000 -0400
+--- sid~/np-debian.h	1970-01-01 01:00:00.000000000 +0100
++++ sid/np-debian.h	2005-10-31 21:15:42.000000000 +0100
 @@ -0,0 +1,25 @@
 +#ifndef _NP_DEBIAN_H_
 +#define _NP_DEBIAN_H_
@@ -56,10 +46,21 @@
 +#define PATH_TO_NTPQ "/usr/bin/ntpq"
 +
 +#endif /* _NP_DEBIAN_H_ */
+diff -urNad sid~/plugins/common.h sid/plugins/common.h
+--- sid~/plugins/common.h	2004-12-10 01:13:43.000000000 +0100
++++ sid/plugins/common.h	2005-10-31 21:16:22.000000000 +0100
+@@ -33,6 +33,7 @@
+  *****************************************************************************/
+ 
+ #include "config.h"
++#include "np-debian.h"
+ 
+ #ifdef HAVE_FEATURES_H
+ #include <features.h>
 diff -urNad sid~/plugins-scripts/utils.pm.in sid/plugins-scripts/utils.pm.in
---- sid~/plugins-scripts/utils.pm.in	2005-10-06 04:33:15.000000000 -0400
-+++ sid/plugins-scripts/utils.pm.in	2005-10-06 04:36:30.000000000 -0400
-@@ -36,13 +36,13 @@
+--- sid~/plugins-scripts/utils.pm.in	2003-04-13 06:25:36.000000000 +0200
++++ sid/plugins-scripts/utils.pm.in	2005-10-31 21:15:42.000000000 +0100
+@@ -35,13 +35,13 @@
  sub is_hostname;
  
  ## updated by autoconf

--- NEW FILE: 22_check_smb_hostaddress.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 22_check_smb_hostaddress.dpatch by  <seanius at localhost.localdomain>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad sid~/plugins-scripts/check_disk_smb.pl sid/plugins-scripts/check_disk_smb.pl
--- sid~/plugins-scripts/check_disk_smb.pl	2005-10-31 21:44:20.000000000 +0100
+++ sid/plugins-scripts/check_disk_smb.pl	2005-10-31 21:44:41.000000000 +0100
@@ -23,7 +23,7 @@
 use POSIX;
 use strict;
 use Getopt::Long;
-use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $verbose);
+use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose);
 use vars qw($PROGNAME);
 use lib utils.pm ;
 use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
@@ -49,7 +49,8 @@
 	 "u=s" => \$opt_u, "username=s" => \$opt_u,
 	 "s=s" => \$opt_s, "share=s"    => \$opt_s,
 	 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
-	 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
+	 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
+	 "a=s" => \$opt_a, "address=s" => \$opt_a);
 
 if ($opt_V) {
 	print_revision($PROGNAME,'$Revision: 1.1 $'); #'
@@ -65,7 +66,7 @@
 # Options checking
 
 ($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
-my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/);
+my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/);
 ($host) || usage("Invalid host: $opt_H\n");
 
 ($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
@@ -142,6 +143,8 @@
 
 my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
 
+my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/);
+
 # end of options checking
 
 
@@ -160,10 +163,21 @@
 # Execute an "ls" on the share using smbclient program
 # get the results into $res
 if (defined($workgroup)) {
-	$res = qx/$smbclient \/\/$host\/$share -W $workgroup -U $user%$pass $smbclientoptions -c ls/;
+	if (defined($address)) {
+		print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
+		$res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls/;
+	} else {
+		print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -c ls\n" if ($verbose);
+		$res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -c ls/;
+	}
 } else {
-	print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
-	$res = qx/$smbclient \/\/$host\/$share -U $user%$pass $smbclientoptions -c ls/;
+	if (defined($address)) {
+		print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
+		$res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -I $address -c ls/;
+	} else {
+		print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
+		$res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -c ls/;
+	}
 }
 #Turn off alarm
 alarm(0);
@@ -239,7 +253,7 @@
 
 sub print_usage () {
 	print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> 
-      -w <warn> -c <crit> [-W <workgroup>] [-P <port>]\n";
+      -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n";
 }
 
 sub print_help () {
@@ -257,6 +271,8 @@
    Share name to be tested
 -W, --workgroup=STRING
    Workgroup or Domain used (Defaults to \"WORKGROUP\")
+-a, --address=IP
+   IP-address of HOST (only necessary if HOST is in another network)
 -u, --user=STRING
    Username to log in to server. (Defaults to \"guest\")
 -p, --password=STRING
diff -urNad sid~/plugins-scripts/check_disk_smb.pl.orig sid/plugins-scripts/check_disk_smb.pl.orig
--- sid~/plugins-scripts/check_disk_smb.pl.orig	1970-01-01 01:00:00.000000000 +0100
+++ sid/plugins-scripts/check_disk_smb.pl.orig	2005-10-31 21:44:20.000000000 +0100
@@ -0,0 +1,280 @@
+#!/usr/bin/perl -w
+#
+#
+# check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port]
+#
+# Nagios host script to get the disk usage from a SMB share
+#
+# Changes and Modifications
+# =========================
+# 7-Aug-1999 - Michael Anthon
+#  Created from check_disk.pl script provided with netsaint_statd (basically
+#  cause I was too lazy (or is that smart?) to write it from scratch)
+# 8-Aug-1999 - Michael Anthon
+#  Modified [warn] and [critical] parameters to accept format of nnn[M|G] to
+#  allow setting of limits in MBytes or GBytes.  Percentage settings for large
+#  drives is a pain in the butt
+# 2-May-2002 - SGhosh fix for embedded perl
+#
+# $Id: 22_check_smb_hostaddress.dpatch,v 1.1 2005/10/31 21:35:50 seanius Exp $
+#
+
+require 5.004;
+use POSIX;
+use strict;
+use Getopt::Long;
+use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $verbose);
+use vars qw($PROGNAME);
+use lib utils.pm ;
+use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
+
+sub print_help ();
+sub print_usage ();
+
+$PROGNAME = "check_disk_smb";
+
+$ENV{'PATH'}='';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
+
+Getopt::Long::Configure('bundling');
+GetOptions
+	("v"   => \$verbose, "verbose"    => \$verbose,
+	 "P=s" => \$opt_P, "port=s"     => \$opt_P,
+	 "V"   => \$opt_V, "version"    => \$opt_V,
+	 "h"   => \$opt_h, "help"       => \$opt_h,
+	 "w=s" => \$opt_w, "warning=s"  => \$opt_w,
+	 "c=s" => \$opt_c, "critical=s" => \$opt_c,
+	 "p=s" => \$opt_p, "password=s" => \$opt_p,
+	 "u=s" => \$opt_u, "username=s" => \$opt_u,
+	 "s=s" => \$opt_s, "share=s"    => \$opt_s,
+	 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
+	 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
+
+if ($opt_V) {
+	print_revision($PROGNAME,'$Revision: 1.1 $'); #'
+	exit $ERRORS{'OK'};
+}
+
+if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
+
+my $smbclient= "$utils::PATH_TO_SMBCLIENT " ;
+my $smbclientoptions= $opt_P ? "-p $opt_P " : "";
+
+
+# Options checking
+
+($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
+my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/);
+($host) || usage("Invalid host: $opt_H\n");
+
+($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
+my $share = $1 if ($opt_s =~ /^([-_.A-Za-z0-9]+\$?)$/);
+($share) || usage("Invalid share: $opt_s\n");
+
+($opt_u) || ($opt_u = shift) || ($opt_u = "guest");
+my $user = $1 if ($opt_u =~ /^([-_.A-Za-z0-9\\]+)$/);
+($user) || usage("Invalid user: $opt_u\n");
+
+($opt_p) || ($opt_p = shift) || ($opt_p = "");
+my $pass = $1 if ($opt_p =~ /(.*)/);
+
+($opt_w) || ($opt_w = shift) || ($opt_w = 85);
+my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
+($warn) || usage("Invalid warning threshold: $opt_w\n");
+
+($opt_c) || ($opt_c = shift) || ($opt_c = 95);
+my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
+($crit) || usage("Invalid critical threshold: $opt_c\n");
+
+# split the type from the unit value
+#Check $warn and $crit for type (%/M/G) and set up for tests
+#P = Percent, K = KBytes
+my $warn_type;
+my $crit_type;
+
+if ($opt_w =~ /^([0-9]+)\%?$/) {
+	$warn = "$1";
+	$warn_type = "P";
+} elsif ($opt_w =~ /^([0-9]+)k$/) {
+	$warn_type = "K";
+	$warn = $1;
+} elsif ($opt_w =~ /^([0-9]+)M$/) {
+	$warn_type = "K";
+	$warn = $1 * 1024;
+} elsif ($opt_w =~ /^([0-9]+)G$/) {
+	$warn_type = "K";
+	$warn = $1 * 1048576;
+}
+if ($opt_c =~ /^([0-9]+)\%?$/) {
+	$crit = "$1";
+	$crit_type = "P";
+} elsif ($opt_c =~ /^([0-9]+)k$/) {
+	$crit_type = "K";
+	$crit = $1;
+} elsif ($opt_c =~ /^([0-9]+)M$/) {
+	$crit_type = "K";
+	$crit = $1 * 1024;
+} elsif ($opt_c =~ /^([0-9]+)G$/) {
+	$crit_type = "K";
+	$crit = $1 * 1048576;
+}
+
+# check if both warning and critical are percentage or size
+unless( ( $warn_type eq "P" && $crit_type eq "P" ) || ( $warn_type ne "P" && $crit_type ne "P" ) ){
+	$opt_w =~ s/\%/\%\%/g;
+	$opt_c =~ s/\%/\%\%/g;
+	usage("Both warning and critical should be same type- warning: $opt_w critical: $opt_c \n");
+}
+
+# verify warning is less than critical
+if ( $warn_type eq "K") {
+	unless ( $warn > $crit) {
+		usage("Disk size: warning ($opt_w) should be greater than critical ($opt_c) \n");
+	}
+}else{
+	unless ( $warn < $crit) {
+		$opt_w =~ s/\%/\%\%/g;
+		$opt_c =~ s/\%/\%\%/g;
+		usage("Percentage: warning ($opt_w) should be less than critical ($opt_c) \n");
+	}
+}
+
+my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
+
+# end of options checking
+
+
+my $state = "OK";
+my $answer = undef;
+my $res = undef;
+my @lines = undef;
+
+# Just in case of problems, let's not hang Nagios
+$SIG{'ALRM'} = sub { 
+	print "No Answer from Client\n";
+	exit $ERRORS{"UNKNOWN"};
+};
+alarm($TIMEOUT);
+
+# Execute an "ls" on the share using smbclient program
+# get the results into $res
+if (defined($workgroup)) {
+	$res = qx/$smbclient \/\/$host\/$share -W $workgroup -U $user%$pass $smbclientoptions -c ls/;
+} else {
+	print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
+	$res = qx/$smbclient \/\/$host\/$share -U $user%$pass $smbclientoptions -c ls/;
+}
+#Turn off alarm
+alarm(0);
+
+#Split $res into an array of lines
+ at lines = split /\n/, $res;
+
+#Get the last line into $_
+$_ = $lines[$#lines];
+#print "$_\n";
+
+#Process the last line to get free space.  
+#If line does not match required regexp, return an UNKNOWN error
+if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
+
+	my ($avail) = ($3*$2)/1024;
+	my ($avail_bytes) = $avail;
+	my ($capper) = int(($3/$1)*100);
+	my ($mountpt) = "\\\\$host\\$share";
+
+
+	if (int($avail / 1024) > 0) {
+		$avail = int($avail / 1024);
+		if (int($avail /1024) > 0) {
+			$avail = (int(($avail / 1024)*100))/100;
+			$avail = $avail ."G";
+		} else {
+			$avail = $avail ."M";
+		}
+	} else {
+		$avail = $avail ."K";
+	}
+
+#print ":$warn:$warn_type:\n";
+#print ":$crit:$crit_type:\n";
+#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
+
+	if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) { 
+		$answer = "Disk ok - $avail ($capper%) free on $mountpt\n";
+	} elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) {
+		$state = "WARNING";
+		$answer = "WARNING: Only $avail ($capper%) free on $mountpt\n";
+	} else {
+		$state = "CRITICAL";
+		$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
+	}
+} else {
+	$answer = "Result from smbclient not suitable\n";
+	$state = "UNKNOWN";
+	foreach (@lines) {
+		if (/(Access denied|NT_STATUS_LOGON_FAILURE)/) {
+			$answer = "Access Denied\n";
+			$state = "CRITICAL";
+			last;
+		}
+		if (/(Unknown host \w*|Connection.*failed)/) {
+			$answer = "$1\n";
+			$state = "CRITICAL";
+			last;
+		}
+		if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
+			$answer = "Invalid share name \\\\$host\\$share\n";
+			$state = "CRITICAL";
+			last;
+		}
+	}
+}
+
+
+print $answer;
+print "$state\n" if ($verbose);
+exit $ERRORS{$state};
+
+sub print_usage () {
+	print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> 
+      -w <warn> -c <crit> [-W <workgroup>] [-P <port>]\n";
+}
+
+sub print_help () {
+	print_revision($PROGNAME,'$Revision: 1.1 $');
+	print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop
+
+Perl Check SMB Disk plugin for Nagios
+
+";
+	print_usage();
+	print "
+-H, --hostname=HOST
+   NetBIOS name of the server
+-s, --share=STRING
+   Share name to be tested
+-W, --workgroup=STRING
+   Workgroup or Domain used (Defaults to \"WORKGROUP\")
+-u, --user=STRING
+   Username to log in to server. (Defaults to \"guest\")
+-p, --password=STRING
+   Password to log in to server. (Defaults to an empty password)
+-w, --warning=INTEGER or INTEGER[kMG]
+   Percent of used space at which a warning will be generated (Default: 85%)
+      
+-c, --critical=INTEGER or INTEGER[kMG]
+   Percent of used space at which a critical will be generated (Defaults: 95%)
+-P, --port=INTEGER
+   Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
+   
+   If thresholds are followed by either a k, M, or G then check to see if that
+   much disk space is available (kilobytes, Megabytes, Gigabytes)
+
+   Warning percentage should be less than critical
+   Warning (remaining) disk space should be greater than critical.
+
+";
+	support();
+}




More information about the Pkg-nagios-changes mailing list