nagios: Added smb and wins service targets.

This commit is contained in:
Timo Makinen 2013-11-15 08:46:04 +02:00
parent 70d894e4b1
commit 95f66a4b3d
5 changed files with 147 additions and 0 deletions

39
nagios/files/check_smb Executable file
View file

@ -0,0 +1,39 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Long qw(:config no_ignore_case);
use Time::HiRes qw/ time sleep /;
sub usage() {
print "Usage: check_smb -H <host>\n"
}
my $host;
my $result = GetOptions(
"H|host=s" => \$host,
);
if (!$host) {
usage();
exit 3;
}
my ($start, $end, $time, @output, $status);
$start = time;
@output = `/usr/bin/smbclient -N -L '$host' 2>&1`;
$status = $?;
$end = time;
$time = sprintf("%.3f", $end - $start);
if ($status != 0) {
print "SMB CRITICAL: " . join(" ", @output);
exit(2);
} else {
foreach(@output) {
next unless /^Domain=.*/;
print "SMB OK: ${time} seconds response time. $_";
exit(0);
}
}

41
nagios/files/check_wins Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/perl -w
use strict;
use Getopt::Long qw(:config no_ignore_case);
use Time::HiRes qw/ time sleep /;
sub usage() {
print "Usage: check_wins -H <host> -q <query> [-t <type>]\n"
}
my ($host, $query, $type);
my $result = GetOptions(
"H|host=s" => \$host,
"q|query=s" => \$query,
"t|type=s" => \$type,
);
if (!$type) {
$type = "00"
}
if (!$host || !$query) {
usage();
exit 3;
}
my ($start, $end, $time);
$start = time;
$result = `/usr/bin/nmblookup -R -U "$host" "$query#$type"`;
$end = time;
$time = sprintf("%.3f", $end - $start);
$result =~ s/\n/: /;
if ($result =~ /name_query failed/) {
print "WINS CRITICAL: ${result}";
exit(2);
} else {
print "WINS OK: ${time} seconds response time. ${result}";
exit(0);
}

View file

@ -162,6 +162,13 @@ define command{
}
# 'check_smb' command definition
define command{
command_name check_smb
command_line $USER1$/check_smb -H $HOSTADDRESS$
}
# 'check_ssh' command definition
define command{
command_name check_ssh
@ -169,6 +176,13 @@ define command{
}
# 'check_wins' command definition
define command{
command_name check_wins
command_line $USER1$/check_wins -H $HOSTADDRESS$ -q $ARG1$
}
# 'check_dig' command definition
define command{
command_name check_dig