[Pkg-nagios-devel] nagios-plugins/debian/patches 00list, 1.9, 1.10 17_check_smb_freespace.dpatch, NONE, 1.1

seanius at haydn.debian.org seanius at haydn.debian.org
Tue Oct 11 07:36:17 UTC 2005


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

Modified Files:
	00list 
Added Files:
	17_check_smb_freespace.dpatch 
Log Message:
check_disk_smb fix


Index: 00list
===================================================================
RCS file: /cvsroot/pkg-nagios/nagios-plugins/debian/patches/00list,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- 00list	9 Oct 2005 22:31:17 -0000	1.9
+++ 00list	11 Oct 2005 07:36:14 -0000	1.10
@@ -6,3 +6,4 @@
 14_check_log_paths.dpatch
 15_check_mrtg_wtf_conditionals.dpatch
 16_check_smtp_protocolfix.dpatch
+17_check_smb_freespace.dpatch

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

@DPATCH@
diff -urNad nagios-plugins~/plugins-scripts/check_disk_smb.pl nagios-plugins/plugins-scripts/check_disk_smb.pl
--- nagios-plugins~/plugins-scripts/check_disk_smb.pl	2005-10-11 09:31:55.000000000 +0200
+++ nagios-plugins/plugins-scripts/check_disk_smb.pl	2005-10-11 09:33:17.000000000 +0200
@@ -87,18 +87,55 @@
 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( ( ($opt_w =~ /([0-9]){1,2}$/ ) && ($opt_c =~ /([0-9]){1,2}$/ )  )|| (( $opt_w =~ /[kMG]/ ) && ($opt_c =~ /[kMG]/) )  ){
+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 ( $opt_w =~ /[kMG]/) {
+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");
 	}
 }
@@ -147,35 +184,6 @@
 	my ($capper) = int(($3/$1)*100);
 	my ($mountpt) = "\\\\$host\\$share";
 
-	#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_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_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;
-	}
 
 	if (int($avail / 1024) > 0) {
 		$avail = int($avail / 1024);




More information about the Pkg-nagios-devel mailing list