For the username, use the following format
Code: Select all
domain/usernameCode: Select all
domain/usernameCode: Select all
/usr/local/nagios/libexec/utils.pmCode: Select all
$PATH_TO_SMBCLIENT = "/usr/bin/smbclient" ;Code: Select all
use lib "/usr/local/nagios/libexec";Code: Select all
# Write test
print "Write test starting\n" if $DEBUG;
$startwrite = Time::HiRes::time();
$fd = $smb->open(">$filename", 0666)
or print "Can't create file:", $!, "\n";
if($fd) {
for ($count = 500; $count >= 1; $count--) {
$smb->write($fd, "Nagios write test Nagios write test Nagios write test at " . $startwrite . " - " . $count . "\n");
}
$smb->close($fd);
$writetime = sprintf("%.3f",Time::HiRes::time()-$startwrite);
$output .= " write at ${writetime}s";
} else {
$errorcode = $ERRORS{'CRITICAL'};
$output .= " write fail";
}
Code: Select all
# Write test
print "Write test starting\n" if $DEBUG;
# create the file
$fd = open(my $fh, '>', $filename);
# populate the file
if($fd) {
for ($count = 500; $count >= 1; $count--) {
print $fh "Nagios write test Nagios write test Nagios write test at " . $startwrite . " - " . $count . "\n";
}
close($fh);
$command = "put $filename ${opt_F}";
# put the file on the remote share
$startwrite = Time::HiRes::time();
qx/$smbclient '\/\/$opt_H\/$opt_R' $opt_P -W $opt_D -U $opt_U -c "$command" 2> \/dev\/null/;
my $writetatus = $?; # should be 0
# analyze error code
if ($writetatus == 0) {
$errorcode = $ERRORS{'OK'} if $errorcode < $ERRORS{'OK'};
$writetime = sprintf("%.3f",Time::HiRes::time()-$startwrite);
$output .= " write at ${writetime}s";
} else {
$errorcode = $ERRORS{'CRITICAL'};
$output .= " write fail";
}
}
Ah! I just remembered that we had to turn off SMB1 off on that server. OK, that explains that. You said "plugins" - as in plural. Do you mean that there are no plugins that will work with SMB2 or 3?tgriep wrote:Another thing I found that could cause that error is that SMB1.0 is deprecated in Windows 2012R2 and the plugins need that to function.
Code: Select all
smbclient -LCode: Select all
smbclient -L "host" -U"user"%"password" -W "domain-or-workgroup"Code: Select all
smbclient -L "host" -U"user"%"password" -W "domain-or-workgroup" -m SMB3Code: Select all
man smbclient
-W|--workgroup=domain
Set the SMB domain of the username. This overrides the default domain which is the domain defined in smb.conf. If the
domain specified is the same as the servers NetBIOS name, it causes the client to log on using the servers local SAM (as
opposed to the Domain SAM).
-m|--max-protocol protocol
This allows the user to select the highest SMB protocol level that smbclient will use to connect to the server. By default
this is set to NT1, which is the highest available SMB1 protocol. To connect using SMB2 or SMB3 protocol, use the strings
SMB2 or SMB3 respectively. Note that to connect to a Windows 2012 server with encrypted transport selecting a max-protocol
of SMB3 is required.
Code: Select all
EVISION=1.1
PROGNAME=`/bin/basename $0`
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
ACCESS_DENIED='NT_STATUS_ACCESS_DENIED'
LOGON_DENIED='NT_STATUS_LOGON_FAILURE'
logon_state=0
acces_state=0
. $PROGPATH/utils.sh
usage () {
echo "\
Nagios plugin to check Windows share
Usage:
$PROGNAME -H <host> -U USERNAME -P PASSWORD -D DOMAIN/WORKGROP -S SHARE
$PROGNAME --help
$PROGNAME --version
"
}
help () {
print_revision $PROGNAME $REVISION
echo; usage; echo; support
}
if [ $# -lt 1 ] || [ $# -gt 6 ]; then
usage
exit $STATE_UNKNOWN
fi
while test -n "$1"; do
case "$1" in
--help | -h)
help
exit $STATE_OK;;
--version | -V)
print_revision $PROGNAME $REVISION
exit $STATE_OK;;
-H)
shift
host=$1;;
-U)
shift
usr=$1;;
-P)
shift
pass=$1;;
-D)
shift
domain=$1;;
-S)
shift
share=$1;;
*)
usage; exit $STATE_UNKNOWN;;
esac
shift
done
stdout=$(smbclient //$host/$share -U "$usr"%"pass" -W $domain -m SMB3 -c dir 2>&1)
logon_state=$(echo $stdout | grep $LOGON_DENIED | wc -l)
acces_state=$(echo $stdout | grep $ACCESS_DENIED | wc -l)
share_state=$(echo "$stdout" | wc -l)
if [ $logon_state -eq 1 ]; then
echo "CRITICAL Authentication problem : Check USER/PWD config"
exit $STATE_CRITICAL
fi
if [ $acces_state -eq 1 ]; then
echo "CRITICAL Authorization problem : Access denied"
exit $STATE_CRITICAL
fi
if [[ $acces_state -eq 0 && $logon_state -eq 0 && $share_state -gt 3 ]]; then
echo "OK Share : $share"
exit $STATE_OK
fi
echo "Unknown state : $share"
exit $STATE_UNKNOWNCode: Select all
$USER1$/check_windows_share -H $HOSTNAME$ -U $ARG1$ -P $ARG2$ -D $ARG3$ -S $ARG4$ $ARG5$Code: Select all
smbclient //servername/sharename -U username%password -W domain -m SMB3 -c dirCode: Select all
$USER1$/check_windows_share -H servername -U username -P password -D domain -S sharename