[Pkg-nagios-changes] [pkg-nagios-plugins] 291/413: add perfdata to check_disk_smb

Jan Wagner waja at moszumanska.debian.org
Tue Nov 26 23:13:34 UTC 2013


This is an automated email from the git hooks/post-receive script.

waja pushed a commit to branch master
in repository pkg-nagios-plugins.

commit 606f04878e0a08f5c07b083c8f6b0ae295000040
Author: Jan Wagner <waja at cyconet.org>
Date:   Thu Feb 23 22:37:16 2012 +0000

    add perfdata to check_disk_smb
---
 debian/changelog                                 |   2 +
 debian/patches/00list                            |   1 +
 debian/patches/03_check_disk_smb_perfdata.dpatch | 102 +++++++++++++++++++++++
 3 files changed, 105 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 05bf11e..599646b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ nagios-plugins (1.4.15-6) UNRELEASED; urgency=low
     duplicate messages when certificate errors occures, thanks Sebastian Harl
     for reporting
   * Add build-arch and build-indep targets to debian/rules
+  * Add 03_check_disk_smb_perfdata.dpatch to add perfdata to check_disk_smb
+   (Closes: #654259), thanks to G. Leimua
 
  -- Jan Wagner <waja at cyconet.org>  Wed, 07 Sep 2011 15:33:55 +0200
 
diff --git a/debian/patches/00list b/debian/patches/00list
index 5b7f8f3..d1bc21d 100644
--- a/debian/patches/00list
+++ b/debian/patches/00list
@@ -11,3 +11,4 @@
 16_check_raduis_fix_format-security.dpatch
 17_check_tcp_fix_duplicate_cert_message.dpatch
 17_check_smtp_fix_duplicate_cert_message.dpatch
+03_check_disk_smb_perfdata.dpatch
diff --git a/debian/patches/03_check_disk_smb_perfdata.dpatch b/debian/patches/03_check_disk_smb_perfdata.dpatch
new file mode 100644
index 0000000..7f8b41b
--- /dev/null
+++ b/debian/patches/03_check_disk_smb_perfdata.dpatch
@@ -0,0 +1,102 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_check_disk_smb_perfdata.dpatch by G. Leimua <gaufrettes.aumiel at gmail.com>
+##
+## DP: Add perfdata fo check_disk_smb (http://bugs.debian.org/654259)
+
+ at DPATCH@
+
+diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
+index 7c81fc2..bca9552 100755
+--- a/plugins-scripts/check_disk_smb.pl
++++ b/plugins-scripts/check_disk_smb.pl
+@@ -166,6 +166,7 @@ my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/);
+ my $state = "OK";
+ my $answer = undef;
+ my $res = undef;
++my $perfdata = "";
+ my @lines = undef;
+ 
+ # Just in case of problems, let's not hang Nagios
+@@ -204,11 +205,23 @@ $_ = $lines[$#lines];
+ #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 ($avail_bytes) = $3 * $2;
++	my ($total_bytes) = $1 * $2;
++	my ($occupied_bytes) = $1 * $2 - $avail_bytes;
++	my ($avail) = $avail_bytes/1024;
+ 	my ($capper) = int(($3/$1)*100);
+ 	my ($mountpt) = "\\\\$host\\$share";
+ 
++	# TODO : why is the kB the standard unit for args ?
++	my ($warn_bytes) = $total_bytes - $warn * 1024;
++	if ($warn_type eq "P") {
++		$warn_bytes = $warn * $1 * $2 / 100;
++	}
++	my ($crit_bytes) = $total_bytes - $crit * 1024;
++	if ($crit_type eq "P") {
++		$crit_bytes = $crit * $1 * $2 / 100;
++	}
++
+ 
+ 	if (int($avail / 1024) > 0) {
+ 		$avail = int($avail / 1024);
+@@ -225,32 +238,37 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
+ #print ":$warn:$warn_type:\n";
+ #print ":$crit:$crit_type:\n";
+ #print ":$avail:$avail_bytes:$capper:$mountpt:\n";
++	$perfdata = "'" . $share . "'=" . $occupied_bytes . 'B;'
++		. $warn_bytes . ';'
++		. $crit_bytes . ';'
++		. '0;'
++		. $total_bytes;
+ 
+-	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))) {
++	if ($occupied_bytes > $crit_bytes) {
++		$state = "CRITICAL";
++		$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt";
++	} elsif ( $occupied_bytes > $warn_bytes ) {
+ 		$state = "WARNING";
+-		$answer = "WARNING: Only $avail ($capper%) free on $mountpt\n";
++		$answer = "WARNING: Only $avail ($capper%) free on $mountpt";
+ 	} else {
+-		$state = "CRITICAL";
+-		$answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
++		$answer = "Disk ok - $avail ($capper%) free on $mountpt";
+ 	}
+ } else {
+-	$answer = "Result from smbclient not suitable\n";
++	$answer = "Result from smbclient not suitable";
+ 	$state = "UNKNOWN";
+ 	foreach (@lines) {
+ 		if (/(Access denied|NT_STATUS_LOGON_FAILURE|NT_STATUS_ACCESS_DENIED)/) {
+-			$answer = "Access Denied\n";
++			$answer = "Access Denied";
+ 			$state = "CRITICAL";
+ 			last;
+ 		}
+ 		if (/(Unknown host \w*|Connection.*failed)/) {
+-			$answer = "$1\n";
++			$answer = "$1";
+ 			$state = "CRITICAL";
+ 			last;
+ 		}
+ 		if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
+-			$answer = "Invalid share name \\\\$host\\$share\n";
++			$answer = "Invalid share name \\\\$host\\$share";
+ 			$state = "CRITICAL";
+ 			last;
+ 		}
+@@ -259,6 +277,8 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
+ 
+ 
+ print $answer;
++print " | " . $perfdata if ($perfdata);
++print "\n";
+ print "$state\n" if ($verbose);
+ exit $ERRORS{$state};
+ 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins.git



More information about the Pkg-nagios-changes mailing list