summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2012-06-23 08:22:08 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2012-06-23 08:22:08 (GMT)
commitd61a3056c598bf030e699a094671727f841eca8c (patch)
treeddc1fabde7e0afcb73f65a1711496ec55c2c46fb /plugins-scripts
parente6df238350588afd93f11501c4c673b07c9733a4 (diff)
downloadmonitoring-plugins-d61a3056c598bf030e699a094671727f841eca8c.tar.gz
check_disk_smb: Add performance data
(Debian #654259 - Charles-Henri Larose)
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_disk_smb.pl44
1 files changed, 32 insertions, 12 deletions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 6783543..43841c3 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