Add a simple script to check nmbd lookups

tags/zabbix-agent-addons-0.2.20-1 0.1.15_el5
Daniel Berteaud 10 years ago
parent 33c78c9eb5
commit 5214d25e14
  1. 2
      zabbix_conf/samba.conf
  2. 29
      zabbix_scripts/check_nmblookup

@ -0,0 +1,2 @@
# Check if nmbd is available and working
UserParameter=samba.nmbd.status,/var/lib/zabbix/bin/check_nmblookup --server=127.0.0.1 --host=linuxsrv

@ -0,0 +1,29 @@
#!/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";
Loading…
Cancel
Save