summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--THANKS.in1
-rwxr-xr-xplugins-scripts/check_disk_smb.pl44
3 files changed, 34 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index b138084a..29ca455f 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ This file documents the major additions and syntax changes between releases.
13 check_sensors now detects faulty sensors unless --ignore-fault is specified (Jan Wagner) 13 check_sensors now detects faulty sensors unless --ignore-fault is specified (Jan Wagner)
14 utils.sh now provides a check_range function (Alex Griffin) 14 utils.sh now provides a check_range function (Alex Griffin)
15 Improved the performance of check_users (Marc Remy) 15 Improved the performance of check_users (Marc Remy)
16 Add perfdata to check_disk_smb (Debian #654259 - Charles-Henri Larose)
16 Updated Nagios::Plugin perl module 17 Updated Nagios::Plugin perl module
17 18
18 FIXES 19 FIXES
diff --git a/THANKS.in b/THANKS.in
index 943acdb0..b9368a42 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -274,3 +274,4 @@ Alex Griffin
274Marc Remy 274Marc Remy
275Matej Vela 275Matej Vela
276Jason Ellison 276Jason Ellison
277Charles-Henri Larose
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 6783543b..43841c36 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 =~ /(.*)/);
166my $state = "OK"; 166my $state = "OK";
167my $answer = undef; 167my $answer = undef;
168my $res = undef; 168my $res = undef;
169my $perfdata = "";
169my @lines = undef; 170my @lines = undef;
170 171
171# Just in case of problems, let's not hang Nagios 172# Just in case of problems, let's not hang Nagios
@@ -204,11 +205,23 @@ $_ = $lines[$#lines];
204#If line does not match required regexp, return an UNKNOWN error 205#If line does not match required regexp, return an UNKNOWN error
205if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) { 206if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
206 207
207 my ($avail) = ($3*$2)/1024; 208 my ($avail_bytes) = $3 * $2;
208 my ($avail_bytes) = $avail; 209 my ($total_bytes) = $1 * $2;
210 my ($occupied_bytes) = $1 * $2 - $avail_bytes;
211 my ($avail) = $avail_bytes/1024;
209 my ($capper) = int(($3/$1)*100); 212 my ($capper) = int(($3/$1)*100);
210 my ($mountpt) = "\\\\$host\\$share"; 213 my ($mountpt) = "\\\\$host\\$share";
211 214
215 # TODO : why is the kB the standard unit for args ?
216 my ($warn_bytes) = $total_bytes - $warn * 1024;
217 if ($warn_type eq "P") {
218 $warn_bytes = $warn * $1 * $2 / 100;
219 }
220 my ($crit_bytes) = $total_bytes - $crit * 1024;
221 if ($crit_type eq "P") {
222 $crit_bytes = $crit * $1 * $2 / 100;
223 }
224
212 225
213 if (int($avail / 1024) > 0) { 226 if (int($avail / 1024) > 0) {
214 $avail = int($avail / 1024); 227 $avail = int($avail / 1024);
@@ -225,32 +238,37 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
225#print ":$warn:$warn_type:\n"; 238#print ":$warn:$warn_type:\n";
226#print ":$crit:$crit_type:\n"; 239#print ":$crit:$crit_type:\n";
227#print ":$avail:$avail_bytes:$capper:$mountpt:\n"; 240#print ":$avail:$avail_bytes:$capper:$mountpt:\n";
241 $perfdata = "'" . $share . "'=" . $occupied_bytes . 'B;'
242 . $warn_bytes . ';'
243 . $crit_bytes . ';'
244 . '0;'
245 . $total_bytes;
228 246
229 if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) { 247 if ($occupied_bytes > $crit_bytes) {
230 $answer = "Disk ok - $avail ($capper%) free on $mountpt\n"; 248 $state = "CRITICAL";
231 } elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) { 249 $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt";
250 } elsif ( $occupied_bytes > $warn_bytes ) {
232 $state = "WARNING"; 251 $state = "WARNING";
233 $answer = "WARNING: Only $avail ($capper%) free on $mountpt\n"; 252 $answer = "WARNING: Only $avail ($capper%) free on $mountpt";
234 } else { 253 } else {
235 $state = "CRITICAL"; 254 $answer = "Disk ok - $avail ($capper%) free on $mountpt";
236 $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n";
237 } 255 }
238} else { 256} else {
239 $answer = "Result from smbclient not suitable\n"; 257 $answer = "Result from smbclient not suitable";
240 $state = "UNKNOWN"; 258 $state = "UNKNOWN";
241 foreach (@lines) { 259 foreach (@lines) {
242 if (/(Access denied|NT_STATUS_LOGON_FAILURE|NT_STATUS_ACCESS_DENIED)/) { 260 if (/(Access denied|NT_STATUS_LOGON_FAILURE|NT_STATUS_ACCESS_DENIED)/) {
243 $answer = "Access Denied\n"; 261 $answer = "Access Denied";
244 $state = "CRITICAL"; 262 $state = "CRITICAL";
245 last; 263 last;
246 } 264 }
247 if (/(Unknown host \w*|Connection.*failed)/) { 265 if (/(Unknown host \w*|Connection.*failed)/) {
248 $answer = "$1\n"; 266 $answer = "$1";
249 $state = "CRITICAL"; 267 $state = "CRITICAL";
250 last; 268 last;
251 } 269 }
252 if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) { 270 if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) {
253 $answer = "Invalid share name \\\\$host\\$share\n"; 271 $answer = "Invalid share name \\\\$host\\$share";
254 $state = "CRITICAL"; 272 $state = "CRITICAL";
255 last; 273 last;
256 } 274 }
@@ -259,6 +277,8 @@ if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) {
259 277
260 278
261print $answer; 279print $answer;
280print " | " . $perfdata if ($perfdata);
281print "\n";
262print "$state\n" if ($verbose); 282print "$state\n" if ($verbose);
263exit $ERRORS{$state}; 283exit $ERRORS{$state};
264 284