From: Paul Frieden Date: Wed, 30 Oct 2019 22:06:06 +0000 (-0500) Subject: Export zone timers via stats channels X-Git-Tag: v9.17.2~83^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=543bab699d4822ecc6c72cd298db99acfb140561;p=thirdparty%2Fbind9.git Export zone timers via stats channels --- diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index b702915adaf..59fabdea899 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -1809,6 +1809,43 @@ zone_xmlrender(dns_zone_t *zone, void *arg) { } TRY0(xmlTextWriterEndElement(writer)); /* serial */ + /* + * Export zone timers to the statistics channel in XML format. For + * master zones, only include the loaded time. For slave zones, also + * include the expires and refresh times. + */ + isc_time_t timestamp; + + result = dns_zone_getloadtime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + + isc_time_formatISO8601(×tamp, buf, 64); + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "loaded")); + TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR buf)); + TRY0(xmlTextWriterEndElement(writer)); + + if (dns_zone_gettype(zone) == dns_zone_slave) { + result = dns_zone_getexpiretime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + isc_time_formatISO8601(×tamp, buf, 64); + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "expires")); + TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR buf)); + TRY0(xmlTextWriterEndElement(writer)); + + result = dns_zone_getrefreshtime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + isc_time_formatISO8601(×tamp, buf, 64); + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "refresh")); + TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR buf)); + TRY0(xmlTextWriterEndElement(writer)); + } + if (statlevel == dns_zonestat_full) { isc_stats_t *zonestats; isc_stats_t *gluecachestats; @@ -2619,6 +2656,40 @@ zone_jsonrender(dns_zone_t *zone, void *arg) { return (ISC_R_NOMEMORY); } + /* + * Export zone timers to the statistics channel in JSON format. For + * master zones, only include the loaded time. For slave zones, also + * include the expires and refresh times. + */ + + isc_time_t timestamp; + + result = dns_zone_getloadtime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + + isc_time_formatISO8601(×tamp, buf, 64); + json_object_object_add(zoneobj, "loaded", json_object_new_string(buf)); + + if (dns_zone_gettype(zone) == dns_zone_slave) { + result = dns_zone_getexpiretime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + isc_time_formatISO8601(×tamp, buf, 64); + json_object_object_add(zoneobj, "expires", + json_object_new_string(buf)); + + result = dns_zone_getrefreshtime(zone, ×tamp); + if (result != ISC_R_SUCCESS) { + goto error; + } + isc_time_formatISO8601(×tamp, buf, 64); + json_object_object_add(zoneobj, "refresh", + json_object_new_string(buf)); + } + if (statlevel == dns_zonestat_full) { isc_stats_t *zonestats; isc_stats_t *gluecachestats;