<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="country-region"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="City"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="place"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Verdana;
color:windowtext;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><b><font size=2 face=Verdana><span lang=EN-IE
style='font-size:10.0pt;font-family:Verdana;font-weight:bold'>My Configuration<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>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.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>Let me elaborate: <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'># nslookup XXX.XXX.XXX.XXX<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>Server:
AAA.BBB.CCC.DDD<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>Non-authoritative
answer:<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>XXX.XXX.X.XXX.in-addr.arpa
canonical name = XXX.XXX-XXX.XXX.X.XXX.in-addr.arpa.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>XXX.XXX-XXX.XXX.X.XXX.in-addr.arpa
name = host.mydomain.com.<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>Authoritative
answers can be found from:<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>....<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>....<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>....<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>#<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><b><font size=2 face=Verdana><span lang=EN-IE
style='font-size:10.0pt;font-family:Verdana;font-weight:bold'>The Problem<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>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. <o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><b><font size=2 face=Verdana><span lang=EN-IE
style='font-size:10.0pt;font-family:Verdana;font-weight:bold'>Proposed Solution<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>I have worked around this problem by modifying
check_dns.c as follows:<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>$ diff
check_dns.old check_dns.c<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>135c135<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>< if
((temp_buffer = strstr (chld_out.line[i], "name = ")))<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>---<o:p></o:p></span></font></p>
<p class=MsoNormal style='margin-left:36.0pt'><font size=2 face="Courier New"><span
lang=EN-IE style='font-size:10.0pt;font-family:"Courier New"'>> if
((temp_buffer = strstr (chld_out.line[i], "name = ")) &&
(NULL == strstr (chld_out.line[i], "canonical name = ")))<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>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.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><b><font size=2 face=Verdana><span lang=EN-IE
style='font-size:10.0pt;font-family:Verdana;font-weight:bold'>Question<o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>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.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>All comments welcome.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'>Many thanks,<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Verdana><span lang=EN-IE style='font-size:
10.0pt;font-family:Verdana'><o:p> </o:p></span></font></p>
<p class=MsoNormal><b><font size=1 face=Verdana><span lang=EN-GB
style='font-size:7.5pt;font-family:Verdana;font-weight:bold'>--<br>
<br>
James Mernin<br>
Senior Software Engineer,</span></font></b><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><b><font size=1 face=Verdana><span lang=EN-GB
style='font-size:7.5pt;font-family:Verdana;font-weight:bold'>Telecommunications
Software & Systems Group,</span></font></b><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><b><font size=1 face=Verdana><span lang=EN-GB
style='font-size:7.5pt;font-family:Verdana;font-weight:bold'>Waterford
Institute of Technology,</span></font></b><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><st1:place w:st="on"><st1:City w:st="on"><b><font size=1
face=Verdana><span lang=EN-GB style='font-size:7.5pt;font-family:Verdana;
font-weight:bold'>Waterford</span></font></b></st1:City><b><font size=1
face=Verdana><span lang=EN-GB style='font-size:7.5pt;font-family:Verdana;
font-weight:bold'>, <st1:country-region w:st="on">Ireland</st1:country-region></span></font></b></st1:place><b><font
size=1 face=Verdana><span lang=EN-GB style='font-size:7.5pt;font-family:Verdana;
font-weight:bold'>.</span></font></b><span lang=EN-GB><o:p></o:p></span></p>
<p class=MsoNormal><b><font size=1 face=Verdana><span lang=EN-GB
style='font-size:8.0pt;font-family:Verdana;font-weight:bold'><o:p> </o:p></span></font></b></p>
<p class=MsoNormal><b><font size=1 color=blue face=Verdana><span lang=EN-GB
style='font-size:7.5pt;font-family:Verdana;color:blue;font-weight:bold'>+353
(0)51 845694</span></font></b><b><font size=1 face=Verdana><span lang=EN-GB
style='font-size:8.0pt;font-family:Verdana;font-weight:bold'> | <a
href="mailto:jmernin@tssg.org">mailto:jmernin@tssg.org</a> | <a
href="http://www.tssg.org/">http://www.tssg.org</a> | <a
href="http://www.wit.ie/">http://www.wit.ie</a><o:p></o:p></span></font></b></p>
<p class=MsoNormal><font size=3 face="Times New Roman"><span lang=EN-IE
style='font-size:12.0pt'><o:p> </o:p></span></font></p>
</div>
</body>
</html>