Forum Discussion

Don_Noel_23994's avatar
Don_Noel_23994
Icon for Nimbostratus rankNimbostratus
Nov 30, 2005

DNS Monitor

I am load balancing DNS servers and the UDP monitor does not effectively test DNS server health. How would I write a custom monitor that could do a DNS query that would determine the nodes health?

 

 

Thank You.
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    We here at DevCentral are the folks who work on the API (iControl) and the onboard packet inspector/scripting language (iRules). If you have a question about building iControl apps or writing iRules, this is the place for you.

     

     

    Unfortunately, this isn't the place for product technical support. We simply aren't staffed to handle that side of things. You'll need to talk to the folks in our product support department for questions like these.

     

     

    They can be easily contacted here: Click here - https://websupport.f5.com/csp/logon.asp

     

     

    A good place to start looking for information is often Click here - http://tech.f5.com/askf5/jsp/combined/index.jsp

     

     

    Best of luck,

     

    -Colin
  • Nicolas_Berthie's avatar
    Nicolas_Berthie
    Historic F5 Account
    I made an external monitor in perl. It sends a DNS request to a specific hostname. Hope this will help.

    
    ! /usr/bin/perl -w
     hostname
    my ($domain)= "www.yahoo.fr";
    my (@addrlist,$name,$altnames,$addrtype,$len,$packaddr);
    my ($ip);
       hostname resolution 
      if (!(($name, $altnames, $addrtype, $len, @addrlist) = gethostbyname ($domain)))
      {
        return "DOWN";
      }
      else
      {
        return "UP";
      }

    Regards,

    Nicolas
  • Does that really work in testing the DNS service on the specified nodes? It looks to me like it makes a call to gethostbyname to resolve "www.yahoo.fr". This will use the local systems nameserver to resolve the name. So from what I can see this only tests your local DNS server as well as yahoo.fr's.

     

     

    How it this testing DNS running on the nodes from a monitoring standpoint? Maybe I'm just missing something...

     

     

    -Joe
  • Hi All,

     

     

    I have a sample script, it work fine in V4.5.x but not in V9. I believe it miss out some perl module bcos when i try to run that script i get an error message look like this,

     

     

    =======================================================

     

    Can't locate Net/DNS.pm in @INC (@INC contains: /usr/lib/perl5/5.8.0/i386-linux- thread-multi /usr/lib/perl5/5.8.0 /usr/lib/perl5/site_perl/5.8.0/i386-linux-thre ad-multi /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl /usr/lib/perl5/ vendor_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/ lib/perl5/vendor_perl /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl 5/5.8.0 .) at ./dns_mon line 5.

     

    BEGIN failed--compilation aborted at ./dns_mon line 5.

     

    ==============================================================

     

     

    below is my sample script, pls give some advise if you think out something to make this work in V9.

     

    ===============================================================

     

    !/usr/local/bin/perl

     

     

     

    use strict;

     

    use Net::DNS;

     

    require 5.005;

     

     

     

    my ($node, $port, @domain) = @ARGV;

     

     

     

    Derive and untaint programname.

     

    my $programname = '/' . $0;

     

    $programname =~ m/^.*\/([^\/]+)$/;

     

    $programname = $1;

     

     

     

    $node =~ m/^(\d+\.\d+\.\d+\.\d+)$/;

     

    $node = $1;

     

     

     

    $port =~ m/^(\d+)$/;

     

    $port = $1;

     

     

     

    Process ID and file where it's to be stored. The format

     

    is significant.

     

     

     

    my $pidfile = "/var/run/$programname.$node..$port.pid";

     

    my $pid = "$$";

     

     

     

    Maintenence. Clean up any existing EAV.

     

     

     

    if (-f $pidfile ) {

     

    open(PID, "<$pidfile");

     

    my $pid = ;

     

    close(PID);

     

    if ( $pid ) {

     

    chomp $pid; $pid =~ m/^(\d+)$/; $pid = $1;

     

    if ( $pid ) {

     

    kill 9, $pid;

     

    }

     

    }

     

    unlink($pidfile);

     

    }

     

     

     

    Create a new maintenence file.

     

     

     

    open(PID, ">$pidfile");

     

    print PID $pid, "\n";

     

    close(PID);

     

     

     

    Connect to the DNS server.

     

    Perform A record lookup

     

    my $res = Net::DNS::Resolver->new;

     

    $res->nameservers($node);

     

    my $ipquery = $res->search("@domain");

     

     

     

    if (!($ipquery))

     

    {

     

    print STDERR "Failed to connect, ", $res->errorstring, "\n";

     

    unlink($pidfile);

     

    exit 1;

     

    }

     

     

     

    print "up\n";

     

     

     

    Clean up.

     

    unlink($pidfile);

     

    exit 0;

     

     

    ===============================================================

     

    regards