From: Evan Hunt Date: Fri, 1 Mar 2013 23:07:40 +0000 (-0800) Subject: [master] add "config-time" to stats/status X-Git-Tag: v9.10.0a1~448^2~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4f9f8fa0528ce843a3bdf7993e94463508d8320e;p=thirdparty%2Fbind9.git [master] add "config-time" to stats/status 3510. [func] "rndc status" and XML statistics channel now report server start and reconfiguration times. [RT #21048] --- diff --git a/CHANGES b/CHANGES index 26126967c80..16124a4ef7b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3510. [func] "rndc status" and XML statistics channel now report + server start and reconfiguration times. [RT #21048] + 3509. [cleanup] Added a product line to version file to allow for easy naming of different products (BIND vs BIND ESV, for example). [RT #32755] diff --git a/bin/named/bind9.xsl b/bin/named/bind9.xsl index df573b7bb60..fa98085b52d 100644 --- a/bin/named/bind9.xsl +++ b/bin/named/bind9.xsl @@ -198,7 +198,13 @@ - Sample time: + Last reconfigured: + + + + + + Current time: diff --git a/bin/named/bind9.xsl.h b/bin/named/bind9.xsl.h index 9d766a175e9..4b13ee08017 100644 --- a/bin/named/bind9.xsl.h +++ b/bin/named/bind9.xsl.h @@ -203,7 +203,13 @@ static char xslmsg[] = " \n" " \n" " \n" - " Sample time:\n" + " Last reconfigured:\n" + " \n" + " \n" + " \n" + " \n" + " \n" + " Current time:\n" " \n" " \n" " \n" diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 407deeee360..dddcdc98e12 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -154,6 +154,7 @@ EXTERN const char * ns_g_engine INIT(NULL); EXTERN int ns_g_listen INIT(3); EXTERN isc_time_t ns_g_boottime; +EXTERN isc_time_t ns_g_configtime; EXTERN isc_boolean_t ns_g_memstatistics INIT(ISC_FALSE); EXTERN isc_boolean_t ns_g_clienttest INIT(ISC_FALSE); EXTERN isc_boolean_t ns_g_dropedns INIT(ISC_FALSE); diff --git a/bin/named/server.c b/bin/named/server.c index 84ce1fdfa40..c6bba0eb73f 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4932,7 +4932,7 @@ load_configuration(const char *filename, ns_server_t *server, isc_portset_t *v4portset = NULL; isc_portset_t *v6portset = NULL; isc_resourcevalue_t nfiles; - isc_result_t result; + isc_result_t result, tresult; isc_uint32_t heartbeat_interval; isc_uint32_t interface_interval; isc_uint32_t reserved; @@ -5834,6 +5834,14 @@ load_configuration(const char *filename, ns_server_t *server, if (isc_net_probeipv6() == ISC_R_SUCCESS) adjust_interfaces(server, ns_g_mctx); + /* + * Record the time of most recent configuration + */ + tresult = isc_time_now(&ns_g_configtime); + if (tresult != ISC_R_SUCCESS) + ns_main_earlyfatal("isc_time_now() failed: %s", + isc_result_totext(result)); + /* Relinquish exclusive access to configuration data. */ if (exclusive) isc_task_endexclusive(server->task); @@ -6464,6 +6472,7 @@ loadconfig(ns_server_t *server) { "reloading configuration failed: %s", isc_result_totext(result)); } + return (result); } @@ -7607,6 +7616,7 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { int zonecount, xferrunning, xferdeferred, soaqueries; unsigned int n; const char *ob = "", *cb = "", *alt = ""; + char boottime[80], configtime[80]; if (ns_g_server->version_set) { ob = " ("; @@ -7624,9 +7634,16 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { soaqueries = dns_zonemgr_getcount(server->zonemgr, DNS_ZONESTATE_SOAQUERY); + isc_time_formathttptimestamp(&ns_g_boottime, boottime, + sizeof(boottime)); + isc_time_formathttptimestamp(&ns_g_configtime, configtime, + sizeof(configtime)); + n = snprintf((char *)isc_buffer_used(text), isc_buffer_availablelength(text), "version: %s%s%s%s\n" + "boot time: %s\n" + "last configured: %s\n" #ifdef ISC_PLATFORM_USETHREADS "CPUs found: %u\n" "worker threads: %u\n" @@ -7642,6 +7659,7 @@ ns_server_status(ns_server_t *server, isc_buffer_t *text) { "tcp clients: %d/%d\n" "server is up and running", ns_g_version, ob, alt, cb, + boottime, configtime, #ifdef ISC_PLATFORM_USETHREADS ns_g_cpus_detected, ns_g_cpus, ns_g_udpdisp, #endif diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index d2e4b8b3c84..7b4d507f2ef 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -880,6 +880,7 @@ zone_xmlrender(dns_zone_t *zone, void *arg) { static isc_result_t generatexml(ns_server_t *server, int *buflen, xmlChar **buf) { char boottime[sizeof "yyyy-mm-ddThh:mm:ssZ"]; + char configtime[sizeof "yyyy-mm-ddThh:mm:ssZ"]; char nowstr[sizeof "yyyy-mm-ddThh:mm:ssZ"]; isc_time_t now; xmlTextWriterPtr writer = NULL; @@ -897,6 +898,7 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) { isc_time_now(&now); isc_time_formatISO8601(&ns_g_boottime, boottime, sizeof boottime); + isc_time_formatISO8601(&ns_g_configtime, configtime, sizeof configtime); isc_time_formatISO8601(&now, nowstr, sizeof nowstr); writer = xmlNewTextWriterDoc(&doc, 0); @@ -1018,6 +1020,9 @@ generatexml(ns_server_t *server, int *buflen, xmlChar **buf) { TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "boot-time")); TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR boottime)); TRY0(xmlTextWriterEndElement(writer)); /* boot-time */ + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "config-time")); + TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR configtime)); + TRY0(xmlTextWriterEndElement(writer)); /* config-time */ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "current-time")); TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR nowstr)); TRY0(xmlTextWriterEndElement(writer)); /* current-time */