Additional scripts for Zabbix agent on Linux to discover and monitor several services
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
540 B

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my %opts;
$opts{server} = '127.0.0.1';
GetOptions(
"server=s" => \$opts{server},
"host=s" => \$opts{host}
);
if (!$opts{host}){
print "You have to specify a hostname to lookup with the --host argument\n";
exit(1);
}
my $res = qx(/usr/bin/nmblookup -U $opts{server} $opts{host});
my @lines = split /\n/, $res;
# Look at the last line
my $resp = $lines[$#lines];
my $status = 0;
if ($resp =~ m/^\d+\.\d+\.\d+\.\d+ $opts{host}/){
$status = 1;
}
print $status . "\n";