check the master/slave status

pyh at mail.nsbeta.info pyh at mail.nsbeta.info
Mon Jan 10 07:40:18 UTC 2011


pyh at mail.nsbeta.info writes: 

> I wrote a nagios plugin for monitoring the status of master/slave DNS.
> Just to check if their serial number is the same. The script shows 
> below,thanks for all your directions.  
> 
> #!/usr/bin/perl
> use strict;
> use Net::DNS;
> use Getopt::Std;  
> 
> my %opts;
> getopts('hm:s:z:', \%opts);
> if ($opts{'h'}) {
>    usage();
> }
> my $master = $opts{'m'} || usage();
> my $slave = $opts{'s'} || usage();
> my $zone = $opts{'z'} || usage();  
> 
> my $s1 = qrsoa($master,$zone);
> my $s2 = qrsoa($slave,$zone);  
> 
> if ($s1 != -1 && $s1 == $s2) {
>    print "OK\n";
>    exit 0;
> } else {
>    print "CRITICAL: zone game.yy.com sync error\n";

Sorry, here should be:
print "CRITICAL: zone $zone sync error\n";
game.yy.com is the special one of our zones. 


>    exit 2;
> }  
> 
> 
> sub qrsoa {
>    my $host = shift;
>    my $zone = shift;
>    my $res   = Net::DNS::Resolver->new(nameservers => [$host]);
>    my $query = $res->query($zone, "SOA");
>    return $query ? ($query->answer)[0]->serial : -1;
> }  
> 
> sub usage {
>    print <<EOF;
>    Usage: $0 -m 8.8.8.8 -s 8.8.4.4 -z example.com
>    -m  master DNS ip or name
>    -s  slave DNS ip or name
>    -z  zone name
>    -h  show this help page
> EOF
>    exit 0;
> }
> _______________________________________________
> bind-users mailing list
> bind-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users



More information about the bind-users mailing list