90 lines
3.6 KiB
Plaintext
Executable file
90 lines
3.6 KiB
Plaintext
Executable file
#! /bin/sh /usr/share/dpatch/dpatch-run
|
|
## 22_check_smb_hostaddress.dpatch by <seanius@localhost.localdomain>
|
|
##
|
|
## DP: Allow checking disk usage via host addresses.
|
|
|
|
@DPATCH@
|
|
diff -urNad sid~/plugins-scripts/check_disk_smb.pl sid/plugins-scripts/check_disk_smb.pl
|
|
--- sid~/plugins-scripts/check_disk_smb.pl 2005-10-31 21:44:20.000000000 +0100
|
|
+++ sid/plugins-scripts/check_disk_smb.pl 2005-10-31 21:44:41.000000000 +0100
|
|
@@ -23,7 +23,7 @@
|
|
use POSIX;
|
|
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 $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 $verbose);
|
|
use vars qw($PROGNAME);
|
|
use lib utils.pm ;
|
|
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
|
|
@@ -49,7 +49,8 @@
|
|
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
|
"s=s" => \$opt_s, "share=s" => \$opt_s,
|
|
"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);
|
|
|
|
if ($opt_V) {
|
|
print_revision($PROGNAME,'$Revision$'); #'
|
|
@@ -65,7 +66,7 @@
|
|
# Options checking
|
|
|
|
($opt_H) || ($opt_H = shift) || usage("Host name not specified\n");
|
|
-my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9]+\$?)$/);
|
|
+my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/);
|
|
($host) || usage("Invalid host: $opt_H\n");
|
|
|
|
($opt_s) || ($opt_s = shift) || usage("Share volume not specified\n");
|
|
@@ -142,6 +143,8 @@
|
|
|
|
my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/);
|
|
|
|
+my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/);
|
|
+
|
|
# end of options checking
|
|
|
|
|
|
@@ -160,10 +163,21 @@
|
|
# Execute an "ls" on the share using smbclient program
|
|
# get the results into $res
|
|
if (defined($workgroup)) {
|
|
- $res = qx/$smbclient \/\/$host\/$share -W $workgroup -U $user%$pass $smbclientoptions -c ls/;
|
|
+ if (defined($address)) {
|
|
+ print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
|
|
+ $res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -I $address -c ls/;
|
|
+ } else {
|
|
+ print "$smbclient " . "\/\/$host\/$share" ." $pass -W $workgroup -U $user $smbclientoptions -c ls\n" if ($verbose);
|
|
+ $res = qx/$smbclient "\/\/$host\/$share" $pass -W $workgroup -U $user $smbclientoptions -c ls/;
|
|
+ }
|
|
} else {
|
|
- print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
|
|
- $res = qx/$smbclient \/\/$host\/$share -U $user%$pass $smbclientoptions -c ls/;
|
|
+ if (defined($address)) {
|
|
+ print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -I $address -c ls\n" if ($verbose);
|
|
+ $res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -I $address -c ls/;
|
|
+ } else {
|
|
+ print "$smbclient " . "\/\/$host\/$share" ." $pass -U $user $smbclientoptions -c ls\n" if ($verbose);
|
|
+ $res = qx/$smbclient "\/\/$host\/$share" $pass -U $user $smbclientoptions -c ls/;
|
|
+ }
|
|
}
|
|
#Turn off alarm
|
|
alarm(0);
|
|
@@ -239,7 +253,7 @@
|
|
|
|
sub print_usage () {
|
|
print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password>
|
|
- -w <warn> -c <crit> [-W <workgroup>] [-P <port>]\n";
|
|
+ -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n";
|
|
}
|
|
|
|
sub print_help () {
|
|
@@ -257,6 +271,8 @@
|
|
Share name to be tested
|
|
-W, --workgroup=STRING
|
|
Workgroup or Domain used (Defaults to \"WORKGROUP\")
|
|
+-a, --address=IP
|
|
+ IP-address of HOST (only necessary if HOST is in another network)
|
|
-u, --user=STRING
|
|
Username to log in to server. (Defaults to \"guest\")
|
|
-p, --password=STRING
|