Menu

#32 check_dns returns green

spong-network
open
nobody
None
5
2008-01-15
2008-01-15
Anonymous
No

...even if the DNS on target host is not running.

I tried dig, nslookup and dig as DNSCMD.
If i try the command /usr/bin/host manually, i get:
host servername servername
;; connection timed out; no servers could be reached

But spong displays green.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    This is likely a change in the nslookup/host/dig tools... e.g. the bind package from isc.

    [tbrown@tom2 ~]$ nslookup -type=A gt3.baremetal.com gt3.baremetal.com
    ;; connection timed out; no servers could be reached

    [tbrown@tom2 ~]$ echo $?
    0

    --------

    safe_exec($cmd,15);

    if ( ($? >> 8) == 0 ) {
    $color = "green";
    $summary = "dns ok";

    $? >> 8 should be the exit value o the process, e.g. what
    my shell is saying the exit codes are ...

    0 >> 8 is still zero :(

    dig seems to return 9, for a dead daemon. (which would work)
    host seems to return 1 (also seems ok)

    this change in spong.conf seems to solve the issue for me, with
    a pretty darn new version of bind:

    #$DNSCMD = "/usr/bin/nslookup";
    $DNSCMD = "/usr/bin/host";

    The old code used Net::DNS if it was available... it's another dependency but at least it doesn't require that completely external packages don't change vague things like exit codes.

     
  • alan premselaar

    alan premselaar - 2008-12-09

    I just wrote a script to cycle through the 3 types of tests (nslookup,host,dig) and check the shifted return codes.

    nslookup will return 0 even if there's a timeout connecting to the specified server
    host returns 1 if there's a timeout connecting to the specified server
    dig returns 9 if there's a timeout connecting to the specified server

    I've run this script on Mac OS X 10.5 as well as Centos 5.2 with identical results.

    either way, it looks like this plugin is pretty basic and should probably be re-written to either return the results of the lookup attempt for additional testing or possibly to use Net::DNS.

     
  • alan premselaar

    alan premselaar - 2008-12-09

    I've whipped up a new check_dns plugin that uses Net::DNS and tested it. I'm including it here for now. I'll work on including it into CVS later (as i'm not a CVS guru)

    alan
    File Added: check_dns

     
  • alan premselaar

    alan premselaar - 2008-12-09

    check_dns that uses Net::DNS

     

Log in to post a comment.