]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Export zone timers via stats channels
authorPaul Frieden <pfrieden@verizonmedia.com>
Wed, 30 Oct 2019 22:06:06 +0000 (17:06 -0500)
committerOndřej Surý <ondrej@isc.org>
Tue, 12 May 2020 06:48:01 +0000 (08:48 +0200)
bin/named/statschannel.c

index b702915adaf3647f0b07552644bd716d3f0e9b2b..59fabdea8992266e5dca8e07e32a22b7ddd715b5 100644 (file)
@@ -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, &timestamp);
+       if (result != ISC_R_SUCCESS) {
+               goto error;
+       }
+
+       isc_time_formatISO8601(&timestamp, 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, &timestamp);
+               if (result != ISC_R_SUCCESS) {
+                       goto error;
+               }
+               isc_time_formatISO8601(&timestamp, buf, 64);
+               TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "expires"));
+               TRY0(xmlTextWriterWriteString(writer, ISC_XMLCHAR buf));
+               TRY0(xmlTextWriterEndElement(writer));
+
+               result = dns_zone_getrefreshtime(zone, &timestamp);
+               if (result != ISC_R_SUCCESS) {
+                       goto error;
+               }
+               isc_time_formatISO8601(&timestamp, 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, &timestamp);
+       if (result != ISC_R_SUCCESS) {
+               goto error;
+       }
+
+       isc_time_formatISO8601(&timestamp, 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, &timestamp);
+               if (result != ISC_R_SUCCESS) {
+                       goto error;
+               }
+               isc_time_formatISO8601(&timestamp, buf, 64);
+               json_object_object_add(zoneobj, "expires",
+                                      json_object_new_string(buf));
+
+               result = dns_zone_getrefreshtime(zone, &timestamp);
+               if (result != ISC_R_SUCCESS) {
+                       goto error;
+               }
+               isc_time_formatISO8601(&timestamp, 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;