From 9a34477b2a53e0a634db111095139b568ff3898a Mon Sep 17 00:00:00 2001 From: Eugene Paskevich Date: Tue, 6 May 2014 22:15:28 +0300 Subject: Revised rsync run statistics generation. - Moved the code from cleanup() to check_rsync() where it looks naturally. - Support the format of speed with commas as new rsync prints out. --- bin/ftpsync | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/bin/ftpsync b/bin/ftpsync index 9a055a9..c30563a 100755 --- a/bin/ftpsync +++ b/bin/ftpsync @@ -107,21 +107,6 @@ cleanup() { # all done. Mail the log, exit. log "Mirrorsync done"; - # Lets get a statistical value - SPEED="unknown" - if [ -f "${LOGDIR}/rsync-${NAME}.log" ]; then - SPEED=$( - SPEEDLINE=$(egrep '[0-9.]+ bytes/sec' "${LOGDIR}/rsync-${NAME}.log") - set "nothing" ${SPEEDLINE} - echo ${8:-""} - ) - if [ -n "${SPEED}" ]; then - SPEED=${SPEED%%.*} - SPEED=$(( $SPEED / 1024 )) - fi - fi - log "Rsync transfer speed: ${SPEED} KB/s" - if [ -n "${MAILTO}" ]; then # In case rsync had something on stderr if [ -s "${LOGDIR}/rsync-${NAME}.error" ]; then @@ -150,6 +135,22 @@ check_rsync() { ret=$1 msg=$2 + # Lets get a statistical value + SPEED="unknown" + if [ -f "${LOGDIR}/rsync-${NAME}.log" ]; then + SPEED=$( + SPEEDLINE=$(egrep '[0-9.,]+ bytes/sec' "${LOGDIR}/rsync-${NAME}.log" | tail -n 1) + set "nothing" ${SPEEDLINE} + echo ${8:-""} + ) + if [ -n "${SPEED}" ]; then + SPEED=${SPEED%%.*} + SPEED=${SPEED//,} + SPEED=$(( $SPEED / 1024 )) + fi + fi + log "Latest recorded rsync transfer speed: ${SPEED} KB/s" + # 24 - vanished source files. Ignored, that should be the target of $UPDATEREQUIRED # and us re-running. If it's not, uplink is broken anyways. case "${ret}" in -- cgit v1.2.3