log_notice(msg.str());
}
}
+
+
+/**
+ * DNS cache record timeout
+ * @param hostname Hostname
+ * @param lastupdated Lastupdated
+ * @param dns_cache_ttl DNS cache TTL
+ * @param current_time Current time
+ */
+void Logger::print_recheck_dns_entry(const std::string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const
+{
+ if ( 1 <= Loglevel )
+ {
+ ostringstream msg;
+ msg << "DNS cache record for host <" << hostname << "> expired: Lastupdated: " << lastupdated << " DNS cache ttl: " << dns_cache_ttl << " Current time: " << current_time << " Checking current DNS cache status." << endl;
+ log_notice(msg.str());
+ }
+}
+
+
+/**
+ * Found following cached DNS record
+ * @param hostname Hostname
+ * @param cached_dns_entry IP
+ */
+void Logger::print_cached_dns_entry(const std::string& hostname, const std::string& cached_dns_entry, const std::string& lastupdated_ip) const
+{
+ if ( 1 <= Loglevel )
+ {
+ ostringstream msg;
+ msg << "Cached DNS record for host <" << hostname << "> : " << cached_dns_entry << " Last updated IP: " << lastupdated_ip << endl;
+ log_notice(msg.str());
+ }
+}
void print_shutdown_parent_succeeded() const;
void print_starting_shutdown_parent() const;
+
+ void print_recheck_dns_entry(const std::string& hostname, const int lastupdated, const int dns_cache_ttl, const int current_time) const;
+
+ void print_cached_dns_entry(const std::string& hostname, const std::string& cached_dns_entry, const std::string& lastupdated_ip) const;
};
#endif
lastupdated = service->get_last_updates()->front();
if ( (lastupdated != 0) && ((lastupdated + service->get_dns_cache_ttl()) < current_time) )
- dns_recheck_ip = IPHelp->dns_query(service->get_hostname());
+ {
+ Log->print_recheck_dns_entry(service->get_hostname(),lastupdated,service->get_dns_cache_ttl(),current_time);
+ string _dns_recheck_ip = IPHelp->dns_query(service->get_hostname());
+ Log->print_cached_dns_entry(service->get_hostname(), _dns_recheck_ip, service->get_actual_ip());
+ if (!_dns_recheck_ip.empty())
+ dns_recheck_ip = _dns_recheck_ip;
+ }
if ( (service->get_actual_ip() != ip) || (dns_recheck_ip != ip) )
service->update(ip,current_time);