nagios: Added smb and wins service targets.
This commit is contained in:
parent
70d894e4b1
commit
95f66a4b3d
5 changed files with 147 additions and 0 deletions
41
nagios/files/check_wins
Executable file
41
nagios/files/check_wins
Executable 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue