From 5214d25e14248b3d4fa412bcb88d76ff2daaff48 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Tue, 6 May 2014 10:15:54 +0200 Subject: [PATCH] Add a simple script to check nmbd lookups --- zabbix_conf/samba.conf | 2 ++ zabbix_scripts/check_nmblookup | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 zabbix_conf/samba.conf create mode 100644 zabbix_scripts/check_nmblookup diff --git a/zabbix_conf/samba.conf b/zabbix_conf/samba.conf new file mode 100644 index 0000000..dc655a7 --- /dev/null +++ b/zabbix_conf/samba.conf @@ -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 diff --git a/zabbix_scripts/check_nmblookup b/zabbix_scripts/check_nmblookup new file mode 100644 index 0000000..581f1f8 --- /dev/null +++ b/zabbix_scripts/check_nmblookup @@ -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";