diff options
-rwxr-xr-x | plugins-scripts/check_disk_smb.pl | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 28c49e8..ad71e6a 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl | |||
@@ -22,7 +22,7 @@ require 5.004; | |||
22 | use POSIX qw(setsid); | 22 | use POSIX qw(setsid); |
23 | use strict; | 23 | use strict; |
24 | use Getopt::Long; | 24 | use Getopt::Long; |
25 | 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); | 25 | 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 $opt_C $verbose); |
26 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
27 | use FindBin; | 27 | use FindBin; |
28 | use lib "$FindBin::Bin"; | 28 | use lib "$FindBin::Bin"; |
@@ -53,7 +53,8 @@ GetOptions | |||
53 | "s=s" => \$opt_s, "share=s" => \$opt_s, | 53 | "s=s" => \$opt_s, "share=s" => \$opt_s, |
54 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, | 54 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, |
55 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, | 55 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, |
56 | "a=s" => \$opt_a, "address=s" => \$opt_a); | 56 | "a=s" => \$opt_a, "address=s" => \$opt_a, |
57 | "C=s" => \$opt_C, "configfile=s" => \$opt_C); | ||
57 | 58 | ||
58 | if ($opt_V) { | 59 | if ($opt_V) { |
59 | print_revision($PROGNAME,'@NP_VERSION@'); #' | 60 | print_revision($PROGNAME,'@NP_VERSION@'); #' |
@@ -91,6 +92,10 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); | |||
91 | my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); | 92 | my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); |
92 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); | 93 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); |
93 | 94 | ||
95 | ($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = ""); | ||
96 | my $configfile = $opt_C if ($opt_C); | ||
97 | usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile); | ||
98 | |||
94 | # Execute the given command line and return anything it writes to STDOUT and/or | 99 | # Execute the given command line and return anything it writes to STDOUT and/or |
95 | # STDERR. (This might be useful for other plugins, too, so it should possibly | 100 | # STDERR. (This might be useful for other plugins, too, so it should possibly |
96 | # be moved to utils.pm.) | 101 | # be moved to utils.pm.) |
@@ -193,6 +198,7 @@ my @cmd = ( | |||
193 | defined($workgroup) ? ("-W", $workgroup) : (), | 198 | defined($workgroup) ? ("-W", $workgroup) : (), |
194 | defined($address) ? ("-I", $address) : (), | 199 | defined($address) ? ("-I", $address) : (), |
195 | defined($opt_P) ? ("-p", $opt_P) : (), | 200 | defined($opt_P) ? ("-p", $opt_P) : (), |
201 | defined($configfile) ? ("-s", $configfile) : (), | ||
196 | "-c", "du" | 202 | "-c", "du" |
197 | ); | 203 | ); |
198 | 204 | ||
@@ -292,7 +298,7 @@ exit $ERRORS{$state}; | |||
292 | 298 | ||
293 | sub print_usage () { | 299 | sub print_usage () { |
294 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> | 300 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> |
295 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n"; | 301 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-C <configfile>]\n"; |
296 | } | 302 | } |
297 | 303 | ||
298 | sub print_help () { | 304 | sub print_help () { |
@@ -318,11 +324,12 @@ Perl Check SMB Disk plugin for monitoring | |||
318 | Password to log in to server. (Defaults to an empty password) | 324 | Password to log in to server. (Defaults to an empty password) |
319 | -w, --warning=INTEGER or INTEGER[kMG] | 325 | -w, --warning=INTEGER or INTEGER[kMG] |
320 | Percent of used space at which a warning will be generated (Default: 85%) | 326 | Percent of used space at which a warning will be generated (Default: 85%) |
321 | |||
322 | -c, --critical=INTEGER or INTEGER[kMG] | 327 | -c, --critical=INTEGER or INTEGER[kMG] |
323 | Percent of used space at which a critical will be generated (Defaults: 95%) | 328 | Percent of used space at which a critical will be generated (Defaults: 95%) |
324 | -P, --port=INTEGER | 329 | -P, --port=INTEGER |
325 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) | 330 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) |
331 | -C, --configfile=STRING | ||
332 | Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation) | ||
326 | 333 | ||
327 | If thresholds are followed by either a k, M, or G then check to see if that | 334 | If thresholds are followed by either a k, M, or G then check to see if that |
328 | much disk space is available (kilobytes, Megabytes, Gigabytes) | 335 | much disk space is available (kilobytes, Megabytes, Gigabytes) |