]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add functions for extracting transfer statistics
authorMichał Kępień <michal@isc.org>
Thu, 31 Jan 2019 14:43:58 +0000 (15:43 +0100)
committerEvan Hunt <each@isc.org>
Thu, 31 Jan 2019 21:55:01 +0000 (16:55 -0500)
Add two helper shell functions to facilitate extracting transfer
statistics from dig output and named log files.

bin/tests/system/conf.sh.common

index a09968802f9eb184eadc6d4f11b68fa5f3330ab7..3304053b9b70af118021fddeda2bec496f533a2b 100644 (file)
@@ -260,6 +260,27 @@ rndc_reconfig() {
     done
 }
 
+# get_dig_xfer_stats: extract transfer statistics from dig output stored
+# in $1, converting them to a format used by some system tests.
+get_dig_xfer_stats() {
+       LOGFILE="$1"
+       echo "messages=`sed -n "s/^;; XFR size: .*messages \([0-9][0-9]*\).*/\1/p" "${LOGFILE}"`"
+       echo "records=`sed -n "s/^;; XFR size: \([0-9][0-9]*\) records.*/\1/p" "${LOGFILE}"`"
+       echo "bytes=`sed -n "s/^;; XFR size: .*bytes \([0-9][0-9]*\).*/\1/p" "${LOGFILE}"`"
+}
+
+# get_named_xfer_stats: from named log file $1, extract transfer
+# statistics for the last transfer for peer $2 and zone $3, converting
+# them to a format used by some system tests.
+get_named_xfer_stats() {
+       LOGFILE="$1"
+       PEER="$2"
+       ZONE="$3"
+       echo "messages=`grep "${PEER}" "${LOGFILE}" | sed -n "s/.*${ZONE}.* \([0-9][0-9]*\) messages.*/\1/p" | tail -1`"
+       echo "records=`grep "${PEER}" "${LOGFILE}" | sed -n "s/.*${ZONE}.* \([0-9][0-9]*\) records.*/\1/p" | tail -1`"
+       echo "bytes=`grep "${PEER}" "${LOGFILE}" | sed -n "s/.*${ZONE}.* \([0-9][0-9]*\) bytes.*/\1/p" | tail -1`"
+}
+
 #
 # Export command paths
 #