[Nagiosplug-devel] Patch to check_ntp_time.c and netutils.c to not resolve hostname if given as an IP address

Frank Fegert fra.nospam.nk at gmx.de
Mon Dec 24 15:02:24 CET 2012


Hello all,

i'd like to propose the attached patch against the current nagios-plugins-1.4.16
sources. Although it's a bit hacky, i tried to accomplish the following with this
patch:
 - Add help output wrt the "-4" and "-6" command line options.
 - Move "is_host()" check to after the evaluation of the "-4" and "-6" command
   line options. Otherwise, when built with "USE_IPV6", the address_family for
   the call to resolve_host_or_addr stays at the default AF_UNSPEC instead of
   being set to AF_INET or AF_INET6.
 - Add check logic to determine if the argument passed to the "-H" command line
   option is already a valid IPv4 or IPv6 address. In this case no name lookup
   with getaddrinfo should be necessary.
   I recently ran into an issue related to this: The check_ntp_time calls were
   configured against the IP adresses of two NTP servers, e.g.:
     check_ntp_time -H 192.168.1.1 -w ... -c ...
     check_ntp_time -H 192.168.2.1 -w ... -c ...
   The IP addresses were deliberately used to be independent of DNS glitches.
   Still, when the companies DNS/AD went half braindead, check_ntp_time started
   complaining about NTP connection issues, steering everyone a bit in the wrong
   direction. In this particular case it was a good thing, because it would've
   been a much longer time before someone would've figured out a only partially
   working DNS/AD ;-)
   See here for an explaination of the "ifdef _AIX":
     http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf2%2Finet_pton.htm
     http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.commtechref%2Fdoc%2Fcommtrf2%2Finet_pton6_zone.htm

Any comments are very welcome!

Thanks & best regards,

    Frank Fegert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios-plugins.patch
Type: text/x-diff
Size: 1766 bytes
Desc: not available
URL: <http://nagios-plugins.org/archive/devel/attachments/20121224/4b3f5feb/attachment.patch>


More information about the Devel mailing list