[Nagiosplug-devel] RFC: gethostbyname instead of getaddrinfo

Holger Weiss holger at CIS.FU-Berlin.DE
Tue Feb 10 17:57:28 CET 2009

* Ton Voon <ton.voon at opsera.com> [2009-02-10 13:38]:
> Found an issue at a customer site which I think requires a change in  
> the plugins which might impact on a lot of things.
> Customer setup is this:
>    - host checks use check_icmp, host address is the DNS name
>    - service checks use a mixture of plugins, including check_tcp
> Customer had a primary DNS failure. A lot of service alerts raised.
> Analysis showed that the host checks were all considered OK and the  
> service checks were "(Service Check timed out)". However, check_nrpe  
> service checks worked correctly.
> I think this is due to the plugins using getaddrinfo (which is a DNS  
> call), rather than using gethostbyname (which is an OS call). In this  
> DNS setup, the OS must be caching the DNS results, hence check_icmp  
> and check_nrpe working correctly. As check_tcp is using a different  
> method, its results are inconsistent with the host results.
> I propose changing all instances of getaddrinfo to gethostbyname in  
> the plugins. This will have an added benefit of reducing the load on  
> DNS servers.

You might be right that the difference is somehow related to getaddrinfo
vs. gethostbyname (dunno), but at least on Linux systems which use the
getaddrinfo implementation from glibc, getaddrinfo usually queries nscd
(if it's running) just as gethostbyname does, so it shouldn't really
make a difference with regard to caching.


More information about the Devel mailing list