diff options
Diffstat (limited to 'plugins-scripts/check_disk_smb.pl')
-rw-r--r--[-rwxr-xr-x] | plugins-scripts/check_disk_smb.pl | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 28c49e8..15d1634 100755..100644 --- 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 $opt_t $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"; |
@@ -43,6 +43,7 @@ $ENV{'ENV'}=''; | |||
43 | Getopt::Long::Configure('bundling'); | 43 | Getopt::Long::Configure('bundling'); |
44 | GetOptions | 44 | GetOptions |
45 | ("v" => \$verbose, "verbose" => \$verbose, | 45 | ("v" => \$verbose, "verbose" => \$verbose, |
46 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, | ||
46 | "P=s" => \$opt_P, "port=s" => \$opt_P, | 47 | "P=s" => \$opt_P, "port=s" => \$opt_P, |
47 | "V" => \$opt_V, "version" => \$opt_V, | 48 | "V" => \$opt_V, "version" => \$opt_V, |
48 | "h" => \$opt_h, "help" => \$opt_h, | 49 | "h" => \$opt_h, "help" => \$opt_h, |
@@ -53,7 +54,8 @@ GetOptions | |||
53 | "s=s" => \$opt_s, "share=s" => \$opt_s, | 54 | "s=s" => \$opt_s, "share=s" => \$opt_s, |
54 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, | 55 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, |
55 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, | 56 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, |
56 | "a=s" => \$opt_a, "address=s" => \$opt_a); | 57 | "a=s" => \$opt_a, "address=s" => \$opt_a, |
58 | "C=s" => \$opt_C, "configfile=s" => \$opt_C); | ||
57 | 59 | ||
58 | if ($opt_V) { | 60 | if ($opt_V) { |
59 | print_revision($PROGNAME,'@NP_VERSION@'); #' | 61 | print_revision($PROGNAME,'@NP_VERSION@'); #' |
@@ -91,6 +93,12 @@ 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])$/); | 93 | my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); |
92 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); | 94 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); |
93 | 95 | ||
96 | ($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = ""); | ||
97 | my $configfile = $opt_C if ($opt_C); | ||
98 | usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile); | ||
99 | |||
100 | if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } | ||
101 | |||
94 | # Execute the given command line and return anything it writes to STDOUT and/or | 102 | # 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 | 103 | # STDERR. (This might be useful for other plugins, too, so it should possibly |
96 | # be moved to utils.pm.) | 104 | # be moved to utils.pm.) |
@@ -193,6 +201,7 @@ my @cmd = ( | |||
193 | defined($workgroup) ? ("-W", $workgroup) : (), | 201 | defined($workgroup) ? ("-W", $workgroup) : (), |
194 | defined($address) ? ("-I", $address) : (), | 202 | defined($address) ? ("-I", $address) : (), |
195 | defined($opt_P) ? ("-p", $opt_P) : (), | 203 | defined($opt_P) ? ("-p", $opt_P) : (), |
204 | defined($configfile) ? ("-s", $configfile) : (), | ||
196 | "-c", "du" | 205 | "-c", "du" |
197 | ); | 206 | ); |
198 | 207 | ||
@@ -292,7 +301,8 @@ exit $ERRORS{$state}; | |||
292 | 301 | ||
293 | sub print_usage () { | 302 | sub print_usage () { |
294 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> | 303 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> |
295 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n"; | 304 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-t timeout] |
305 | [-C <configfile>]\n"; | ||
296 | } | 306 | } |
297 | 307 | ||
298 | sub print_help () { | 308 | sub print_help () { |
@@ -318,11 +328,14 @@ Perl Check SMB Disk plugin for monitoring | |||
318 | Password to log in to server. (Defaults to an empty password) | 328 | Password to log in to server. (Defaults to an empty password) |
319 | -w, --warning=INTEGER or INTEGER[kMG] | 329 | -w, --warning=INTEGER or INTEGER[kMG] |
320 | Percent of used space at which a warning will be generated (Default: 85%) | 330 | Percent of used space at which a warning will be generated (Default: 85%) |
321 | |||
322 | -c, --critical=INTEGER or INTEGER[kMG] | 331 | -c, --critical=INTEGER or INTEGER[kMG] |
323 | Percent of used space at which a critical will be generated (Defaults: 95%) | 332 | Percent of used space at which a critical will be generated (Defaults: 95%) |
333 | -t, --timeout=INTEGER | ||
334 | Seconds before connection times out (Default: 15) | ||
324 | -P, --port=INTEGER | 335 | -P, --port=INTEGER |
325 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) | 336 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) |
337 | -C, --configfile=STRING | ||
338 | Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation) | ||
326 | 339 | ||
327 | If thresholds are followed by either a k, M, or G then check to see if that | 340 | 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) | 341 | much disk space is available (kilobytes, Megabytes, Gigabytes) |