Commit 4f9f8fa0 authored by Evan Hunt's avatar Evan Hunt
Browse files

[master] add "config-time" to stats/status

3510.	[func]		"rndc status" and XML statistics channel now report
			server start and reconfiguration times. [RT #21048]
parent 53a4e185
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]
......
......@@ -198,7 +198,13 @@
</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>
......
......@@ -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"
......
......@@ -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);
......
......@@ -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
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment