Page 1 of 1

Reset Nagios DNS Cache

Posted: Mon Jul 13, 2015 11:30 am
by vmesquita
Hi,

We have a few hosts with the address field filled with it's cname and not IP. This is on purpose: this way, when we migrate to an alternative site, the current working server keeps being monitored. However, the only way we found so far to reset the IP nagios associates with a given name is to reboot the server. Is there a way to make nagios search for new DNS information? Restarting the service also doesn't work.

Re: Reset Nagios DNS Cache

Posted: Mon Jul 13, 2015 11:38 am
by abrist
There are multiple ways to flush the DNS cache depending on what daemon you use. Also, you could have entries hardcoded into /etc/hosts. See the following document for info on flushing the cache:
http://www.cyberciti.biz/faq/rhel-debia ... dns-cache/

Re: Reset Nagios DNS Cache

Posted: Mon Jul 13, 2015 11:40 am
by jdalrymple
vmesquita wrote:Restarting the service also doesn't work.
Actually - restarting the Nagios service *should* be the way to handle this. Nagios does it's DNS resolution at the time that the configs are read. Perhaps you're getting bitten by retention data - I've never fiddled with this to understand how it works deep under the hood. I'll do that now.

** EDIT Update **

Verified. I setup a check that just runs ifconfig using check_by_ssh. See attachments...

Sooo... is it possible that you're pointing towards slow replicating DNS servers in your environment or some such? The default XI config seems to react properly to a monitoring engine restart.

Re: Reset Nagios DNS Cache

Posted: Wed Jul 15, 2015 11:08 am
by vmesquita
Hi jdalrymple,

Nagios was poiting to the old IP address 2 days after the change, and DNS is configured with 1 hour time to live. What was odd is that if I ping the name, I get the correct IP address, however restarting and reloading Nagios didn't change anything, it kept pointing to the old address until I rebooted.the whole server.

Next time times happens, I'll try the strategies on the document you posted before and report back.

Re: Reset Nagios DNS Cache

Posted: Wed Jul 15, 2015 11:11 am
by jdalrymple
I would verify that Nagios is restarting properly and that you don't have multiple Nagios monitoring engine processes running. As you can see from my demonstration, it works as advertised.