<th>Messages Received</th>
<th>Records Received</th>
<th>Bytes Received</th>
+ <th>Transfer Rate (B/s)</th>
</tr>
</thead>
<tbody>
<td><xsl:value-of select="nmsg"/></td>
<td><xsl:value-of select="nrecs"/></td>
<td><xsl:value-of select="nbytes"/></td>
+ <td><xsl:value-of select="rate"/></td>
</tr>
</xsl:for-each>
</tbody>
unsigned int nmsg = 0;
unsigned int nrecs = 0;
uint64_t nbytes = 0;
+ uint64_t rate = 0;
statlevel = dns_zone_getstatlevel(zone);
if (statlevel == dns_zonestat_none) {
TRY0(xmlTextWriterEndElement(writer));
if (is_running) {
- dns_xfrin_getstats(xfr, &nmsg, &nrecs, &nbytes);
+ dns_xfrin_getstats(xfr, &nmsg, &nrecs, &nbytes, &rate);
}
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "nmsg"));
TRY0(xmlTextWriterWriteFormatString(writer, "%u", nmsg));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "nbytes"));
TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64, nbytes));
TRY0(xmlTextWriterEndElement(writer));
+ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "rate"));
+ TRY0(xmlTextWriterWriteFormatString(writer, "%" PRIu64, rate));
+ TRY0(xmlTextWriterEndElement(writer));
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "ixfr"));
if (is_running && is_first_data_received) {
unsigned int nmsg = 0;
unsigned int nrecs = 0;
uint64_t nbytes = 0;
+ uint64_t rate = 0;
statlevel = dns_zone_getstatlevel(zone);
if (statlevel == dns_zonestat_none) {
}
if (is_running) {
- dns_xfrin_getstats(xfr, &nmsg, &nrecs, &nbytes);
+ dns_xfrin_getstats(xfr, &nmsg, &nrecs, &nbytes, &rate);
}
json_object_object_add(xfrinobj, "nmsg",
json_object_new_int64((int64_t)nmsg));
xfrinobj, "nbytes",
json_object_new_int64(nbytes > INT64_MAX ? INT64_MAX
: (int64_t)nbytes));
+ json_object_object_add(xfrinobj, "rate",
+ json_object_new_int64(rate > INT64_MAX
+ ? INT64_MAX
+ : (int64_t)rate));
if (is_running && is_first_data_received) {
json_object_object_add(
64-bit unsigned Integer. This is the number of usable bytes
of DNS data. It does not include transport overhead.
+ ``Transfer Rate (B/s)`` (``rate``)
+ 64 bit unsigned Integer. This is the average zone transfer rate in
+ bytes-per-second during the latest full interval that is configured by the
+ :any:`min-transfer-rate-in` configuration option. If no such interval
+ has passed yet, then the overall average rate is reported instead.
+
.. note::
Depending on the current state of the transfer, some of the
values may be empty or set to ``-`` (meaning "not available").
void
dns_xfrin_getstats(dns_xfrin_t *xfr, unsigned int *nmsgp, unsigned int *nrecsp,
- uint64_t *nbytesp);
+ uint64_t *nbytesp, uint64_t *ratep);
/*%<
* Get various statistics values of the xfrin object: number of the received
- * messages, number of the received records, number of the received bytes.
+ * messages, number of the received records, number of the received bytes,
+ * and the average transfer rate (in bytes-per-second) during the last full
+ * 'min-transfer-rate-in <bytes> <minutes>' minutes interval. If no such
+ * interval has passed yet, then the overall average rate is reported instead.
*
* Requires:
*\li 'xfr' is a valid dns_xfrin_t.
atomic_uint nrecs; /*%< Number of records recvd */
atomic_uint_fast64_t nbytes; /*%< Number of bytes received */
_Atomic(isc_time_t) start; /*%< Start time of the transfer */
+ atomic_uint_fast64_t rate_bytes_per_second;
_Atomic(dns_transport_type_t) soa_transport_type;
atomic_uint_fast32_t end_serial;
const uint64_t nbytes = atomic_load_relaxed(&xfr->nbytes);
const uint64_t min = dns_zone_getminxfrratebytesin(xfr->zone);
+ uint64_t rate = nbytes - xfr->nbytes_saved;
- if (nbytes - xfr->nbytes_saved < min) {
+ if (rate < min) {
isc_timer_stop(xfr->min_rate_timer);
xfrin_fail(xfr, ISC_R_TIMEDOUT,
"minimum transfer rate reached");
} else {
xfr->nbytes_saved = nbytes;
+
+ /*
+ * Calculate and store for the statistics channel the transfer
+ * rate in bytes-per-second for the latest interval.
+ */
+ rate /= dns_zone_getminxfrratesecondsin(xfr->zone);
+ atomic_store_relaxed(&xfr->rate_bytes_per_second, rate);
}
}
void
dns_xfrin_getstats(dns_xfrin_t *xfr, unsigned int *nmsgp, unsigned int *nrecsp,
- uint64_t *nbytesp) {
+ uint64_t *nbytesp, uint64_t *ratep) {
REQUIRE(VALID_XFRIN(xfr));
REQUIRE(nmsgp != NULL && nrecsp != NULL && nbytesp != NULL);
+ uint64_t rate = atomic_load_relaxed(&xfr->rate_bytes_per_second);
+ if (rate == 0) {
+ /*
+ * Likely the first 'min-transfer-rate-in <bytes> <minutes>'
+ * minutes interval hasn't passed yet. Calculate the overall
+ * average transfer rate instead.
+ */
+ isc_time_t now = isc_time_now();
+ isc_time_t start = atomic_load_relaxed(&xfr->start);
+ uint64_t sec = isc_time_microdiff(&now, &start) / US_PER_SEC;
+ if (sec > 0) {
+ rate = atomic_load_relaxed(&xfr->nbytes) / sec;
+ }
+ }
+
SET_IF_NOT_NULL(nmsgp, atomic_load_relaxed(&xfr->nmsg));
SET_IF_NOT_NULL(nrecsp, atomic_load_relaxed(&xfr->nrecs));
SET_IF_NOT_NULL(nbytesp, atomic_load_relaxed(&xfr->nbytes));
+ SET_IF_NOT_NULL(ratep, rate);
}
const isc_sockaddr_t *