aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts
diff options
context:
space:
mode:
authorGravatar Claudio Kuenzler <ck@claudiokuenzler.com> 2022-03-17 10:01:50 +0100
committerGravatar GitHub <noreply@github.com> 2022-03-17 10:01:50 +0100
commit9a659f46ffb5b183f91879b08bad7822548ae662 (patch)
tree1e5e96d0560b02e019c0f481e98c25cb6230fb91 /plugins-scripts
parent605405557102c04e740fc3249675cc5154436d11 (diff)
downloadmonitoring-plugins-9a659f46ffb5b183f91879b08bad7822548ae662.tar.gz
Add configfile feature to check_disk_smb (#1402)
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_disk_smb.pl15
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 28c49e84..ad71e6a2 100755
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -22,7 +22,7 @@ require 5.004;
use POSIX qw(setsid);
use strict;
use Getopt::Long;
-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);
+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);
use vars qw($PROGNAME);
use FindBin;
use lib "$FindBin::Bin";
@@ -53,7 +53,8 @@ GetOptions
"s=s" => \$opt_s, "share=s" => \$opt_s,
"W=s" => \$opt_W, "workgroup=s" => \$opt_W,
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
- "a=s" => \$opt_a, "address=s" => \$opt_a);
+ "a=s" => \$opt_a, "address=s" => \$opt_a,
+ "C=s" => \$opt_C, "configfile=s" => \$opt_C);
if ($opt_V) {
print_revision($PROGNAME,'@NP_VERSION@'); #'
@@ -91,6 +92,10 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
($crit) || usage("Invalid critical threshold: $opt_c\n");
+($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = "");
+my $configfile = $opt_C if ($opt_C);
+usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile);
+
# Execute the given command line and return anything it writes to STDOUT and/or
# STDERR. (This might be useful for other plugins, too, so it should possibly
# be moved to utils.pm.)
@@ -193,6 +198,7 @@ my @cmd = (
defined($workgroup) ? ("-W", $workgroup) : (),
defined($address) ? ("-I", $address) : (),
defined($opt_P) ? ("-p", $opt_P) : (),
+ defined($configfile) ? ("-s", $configfile) : (),
"-c", "du"
);
@@ -292,7 +298,7 @@ exit $ERRORS{$state};
sub print_usage () {
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
- -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n";
+ -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-C <configfile>]\n";
}
sub print_help () {
@@ -318,11 +324,12 @@ Perl Check SMB Disk plugin for monitoring
Password to log in to server. (Defaults to an empty password)
-w, --warning=INTEGER or INTEGER[kMG]
Percent of used space at which a warning will be generated (Default: 85%)
-
-c, --critical=INTEGER or INTEGER[kMG]
Percent of used space at which a critical will be generated (Defaults: 95%)
-P, --port=INTEGER
Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
+-C, --configfile=STRING
+ Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation)
If thresholds are followed by either a k, M, or G then check to see if that
much disk space is available (kilobytes, Megabytes, Gigabytes)