summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2016-01-01 23:11:07 +0100
committerPeter Palfrader <peter@palfrader.org>2016-01-01 23:11:07 +0100
commit164a56fbf1c51b66cf51b5b6a1f22eedfbd507a2 (patch)
treeb36f96942f24e3afe609eb36d9f5a2c3eaada75f
parente8fe78707f9bc911c87fe1463139fdda773d9420 (diff)
Try to extract bytes transferred from rsync logs and put them and rsync time into the trace file
-rwxr-xr-xbin/ftpsync15
1 files changed, 15 insertions, 0 deletions
diff --git a/bin/ftpsync b/bin/ftpsync
index eea62cf..788ffcc 100755
--- a/bin/ftpsync
+++ b/bin/ftpsync
@@ -367,6 +367,9 @@ CALLBACKKEY=${CALLBACKKEY:-"none"}
# General excludes. Don't list architecture specific stuff here, use ARCH_EXCLUDE for that!
EXCLUDE=${EXCLUDE:-""}
+# collect some stats
+STATS_TOTAL_RSYNC_TIME=0
+
# The temp directory used by rsync --delay-updates is not
# world-readable remotely. Always exclude it to avoid errors.
EXCLUDE="${EXCLUDE} --exclude=.~tmp~/"
@@ -503,9 +506,12 @@ while [ -e "${UPDATEREQUIRED}" ]; do
set +e
# Step one, sync everything except Packages/Releases
+ rsync_started=$(date +%s)
${RSYNC} ${RSYNC_OPTIONS} ${RSYNC_OPTIONS1} ${EXCLUDE} ${SOURCE_EXCLUDE} \
${RSYNCPTH}::${RSYNC_PATH} "${TO}" >>"${LOGDIR}/rsync-${NAME}.log" 2>>"${LOGDIR}/rsync-${NAME}.error"
result=$?
+ rsync_ended=$(date +%s)
+ STATS_TOTAL_RSYNC_TIME=$(( STATS_TOTAL_RSYNC_TIME + rsync_ended - rsync_started ))
set -e
log "Back from rsync with returncode ${result}"
@@ -637,6 +643,15 @@ if [ "xtruex" = "x${SYNCSTAGE2}x" ] || [ "xtruex" = "x${SYNCALL}x" ]; then
out="GUESSED:{${ARCHLIST}}"
echo "Architectures: ${out}"
echo "Upstream-mirror: ${RSYNC_HOST}"
+ total=0
+ for bytes in $(egrep 'Total bytes received: ' "${LOGDIR}/rsync-${NAME}.log" | awk -F: '{print $2}'); do
+ bytes=${bytes//,}
+ total=$((total + bytes))
+ done
+ echo "Total bytes received in rsync: ${total}"
+ echo "Total time spent in rsync: ${STATS_TOTAL_RSYNC_TIME}"
+ rate=$(( total / STATS_TOTAL_RSYNC_TIME ))
+ echo "Average rate: ${rate} B/s"
fi # full trace
fi # other traces
} > "${TO}/${TRACE}.new"