]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] add "config-time" to stats/status
authorEvan Hunt <each@isc.org>
Fri, 1 Mar 2013 23:07:40 +0000 (15:07 -0800)
committerEvan Hunt <each@isc.org>
Fri, 1 Mar 2013 23:07:40 +0000 (15:07 -0800)
3510. [func] "rndc status" and XML statistics channel now report
server start and reconfiguration times. [RT #21048]

CHANGES
bin/named/bind9.xsl
bin/named/bind9.xsl.h
bin/named/include/named/globals.h
bin/named/server.c
bin/named/statschannel.c

diff --git a/CHANGES b/CHANGES
index 26126967c80e476a78a68bb43a7d864eb1665254..16124a4ef7b314dd017a1c1eca6331d4a3af1088 100644 (file)
--- 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]
index df573b7bb60b4206568af1ff0b169eceb0367540..fa98085b52d3a2a125e125c29274056cc19ca69c 100644 (file)
             </td>
           </tr>
           <tr>
-            <th>Sample time:</th>
+            <th>Last reconfigured:</th>
+            <td>
+              <xsl:value-of select="server/config-time"/>
+            </td>
+          </tr>
+          <tr>
+            <th>Current time:</th>
             <td>
               <xsl:value-of select="server/current-time"/>
             </td>
index 9d766a175e902c400e8a08d9d33814bca7deaa98..4b13ee08017f0a75eecdbfeab99e957cfcf7fa1e 100644 (file)
@@ -203,7 +203,13 @@ static char xslmsg[] =
        " </td>\n"
        " </tr>\n"
        " <tr>\n"
-       " <th>Sample time:</th>\n"
+       " <th>Last reconfigured:</th>\n"
+       " <td>\n"
+       " <xsl:value-of select=\"server/config-time\"/>\n"
+       " </td>\n"
+       " </tr>\n"
+       " <tr>\n"
+       " <th>Current time:</th>\n"
        " <td>\n"
        " <xsl:value-of select=\"server/current-time\"/>\n"
        " </td>\n"
index 407deeee3603a09189fbab0731b4b68f8d0b0f07..dddcdc98e12d9121213cd7a3929f6a57b6c7e8ed 100644 (file)
@@ -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);
index 84ce1fdfa400d0892522d83e6f3be2bf04426a1b..c6bba0eb73fc689817963fd4b2967cfe7027df1e 100644 (file)
@@ -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
index d2e4b8b3c849a96e4e2357e1d5a81478db1076f9..7b4d507f2ef61d2207db847a5d8d3074a5d8d6b5 100644 (file)
@@ -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 */