[Nagiosplug-devel] check_dns issue

James Mernin jmernin at tssg.org
Mon Aug 11 22:31:59 CEST 2008


My Configuration

I would like to use the check_dns plugin (that is included in
nagios-plugins-1.4.12) to verify both forward and reverse DNS lookups for
one of our domains. I am reliably informed that since we don't actually own
the IP space where our servers reside, we have only been given partial
control over the DNS setup. As a result, we get somewhat unusual responses
from a straightforward (reverse) nslookup on some of our IP addresses.

 

Let me elaborate: 

 

# nslookup XXX.XXX.XXX.XXX

Server:         AAA.BBB.CCC.DDD

 

Non-authoritative answer:

XXX.XXX.X.XXX.in-addr.arpa    canonical name =
XXX.XXX-XXX.XXX.X.XXX.in-addr.arpa.

XXX.XXX-XXX.XXX.X.XXX.in-addr.arpa   name = host.mydomain.com.

 

Authoritative answers can be found from:

....

....

....

#

 

The Problem

When I use the check_dns plugin to test this reverse lookup, it seems to
return a list of 2 comma-separated matches for the hostname, and this makes
it very messy to write a clean nagios command based around check_dns.
Looking at the source (check_dns.c) I see that on line 135, it is matching
any line of output from the nslookup response that contains the string "name
= " and appending this to a list of host names associated with this IP
address.  

 

Proposed Solution

I have worked around this problem by modifying check_dns.c as follows:

 

$ diff check_dns.old check_dns.c

135c135

< if ((temp_buffer = strstr (chld_out.line[i], "name = ")))

---

> if ((temp_buffer = strstr (chld_out.line[i], "name = ")) && (NULL ==
strstr (chld_out.line[i], "canonical name = ")))

 

This change tells the plugin to ignore any nslookup output containing the
string "canonical name = " but still matches those containing "name = ".
And, for me, it does what I need.

 

Question

So, my question is this. Is the above change valid and should it be included
in the next release, or perhaps a command-line option added to cater for
such situations.

 

All comments welcome.

 

Many thanks,

 

--
 
James Mernin
Senior Software Engineer,

Telecommunications Software & Systems Group,

Waterford Institute of Technology,

Waterford, Ireland.

 

+353 (0)51 845694 | mailto:jmernin at tssg.org | http://www.tssg.org
<http://www.tssg.org/>  | http://www.wit.ie <http://www.wit.ie/> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20080811/7d507fe3/attachment.html>


More information about the Devel mailing list