Quellcode durchsuchen

check_disk_smb: Add configfile feature

Manually implemented because of conflicts.
John C. Frickson vor 8 Jahren
Ursprung
Commit
e381332b62
3 geänderte Dateien mit 16 neuen und 6 gelöschten Zeilen
  1. 1 0
      NEWS
  2. 1 0
      THANKS.in
  3. 14 6
      plugins-scripts/check_disk_smb.pl

+ 1 - 0
NEWS

@@ -3,6 +3,7 @@ This file documents the major additions and syntax changes between releases.
 2.3.0 xxxx-xx-xx
 2.3.0 xxxx-xx-xx
 	ENHANCEMENTS
 	ENHANCEMENTS
 	check_ping: plugin output will now include hostname and IP address
 	check_ping: plugin output will now include hostname and IP address
+	check_disk_smb: Add configfile feature
 
 
 
 
 2.2.2 xxxx-xx-xx
 2.2.2 xxxx-xx-xx

+ 1 - 0
THANKS.in

@@ -59,6 +59,7 @@ Christoph Schell
 Christopher Maser
 Christopher Maser
 Christopher Schultz
 Christopher Schultz
 Cire Iriarte
 Cire Iriarte
+Claudio Kuenzler
 Cliff Rice
 Cliff Rice
 Collin Fair
 Collin Fair
 Cove Schneider
 Cove Schneider

+ 14 - 6
plugins-scripts/check_disk_smb.pl

@@ -22,7 +22,7 @@ require 5.004;
 use POSIX;
 use POSIX;
 use strict;
 use strict;
 use Getopt::Long;
 use Getopt::Long;
-use vars qw($opt_P $opt_V $opt_h $opt_H $opt_k $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_k $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $verbose);
 use vars qw($PROGNAME);
 use vars qw($PROGNAME);
 use FindBin;
 use FindBin;
 use lib "$FindBin::Bin";
 use lib "$FindBin::Bin";
@@ -52,7 +52,8 @@ GetOptions
 	 "s=s" => \$opt_s, "share=s"    => \$opt_s,
 	 "s=s" => \$opt_s, "share=s"    => \$opt_s,
 	 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
 	 "W=s" => \$opt_W, "workgroup=s" => \$opt_W,
 	 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
 	 "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) {
 if ($opt_V) {
 	print_revision($PROGNAME,'@NP_VERSION@'); #'
 	print_revision($PROGNAME,'@NP_VERSION@'); #'
@@ -90,6 +91,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])$/);
 my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/);
 ($crit) || usage("Invalid critical threshold: $opt_c\n");
 ($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
 # 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
 # STDERR.  (This might be useful for other plugins, too, so it should possibly
 # be moved to utils.pm.)
 # be moved to utils.pm.)
@@ -191,6 +196,7 @@ my @cmd = (
 	defined($address) ? ("-I", $address) : (),
 	defined($address) ? ("-I", $address) : (),
 	defined($opt_P) ? ("-p", $opt_P) : (),
 	defined($opt_P) ? ("-p", $opt_P) : (),
 	defined($opt_k) ? ("-k") : (),
 	defined($opt_k) ? ("-k") : (),
+	defined($configfile) ? ("-s, $configfile") : (),
 	"-c", "du"
 	"-c", "du"
 );
 );
 
 
@@ -289,8 +295,9 @@ print "$state\n" if ($verbose);
 exit $ERRORS{$state};
 exit $ERRORS{$state};
 
 
 sub print_usage () {
 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";
+	print "Usage: $PROGNAME -H <host> -s <share> -u <user> 
+      -p <password> -w <warn> -c <crit> [-W <workgroup>] [-P <port>] 
+      [-a <IP>] [-C <configfile>]\n";
 }
 }
 
 
 sub print_help () {
 sub print_help () {
@@ -316,12 +323,13 @@ Perl Check SMB Disk plugin for Nagios
    Password to log in to server. (Defaults to an empty password)
    Password to log in to server. (Defaults to an empty password)
 -w, --warning=INTEGER or INTEGER[kMG]
 -w, --warning=INTEGER or INTEGER[kMG]
    Percent of used space at which a warning will be generated (Default: 85%)
    Percent of used space at which a warning will be generated (Default: 85%)
-      
 -c, --critical=INTEGER or INTEGER[kMG]
 -c, --critical=INTEGER or INTEGER[kMG]
    Percent of used space at which a critical will be generated (Defaults: 95%)
    Percent of used space at which a critical will be generated (Defaults: 95%)
 -P, --port=INTEGER
 -P, --port=INTEGER
    Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default)
    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
    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)
    much disk space is available (kilobytes, Megabytes, Gigabytes)