diff options
author | Eugene Paskevich <eugene@raptor.kiev.ua> | 2014-05-06 22:15:28 +0300 |
---|---|---|
committer | Joerg Jaspert <joerg@debian.org> | 2014-05-08 10:37:42 +0200 |
commit | 9a34477b2a53e0a634db111095139b568ff3898a (patch) | |
tree | 1a0e29152d2718f46c8ed89dbeb9ee48793e5839 | |
parent | 9aa0ea4ff5d55226f14fd5558249a8e27fb02e68 (diff) |
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.
-rwxr-xr-x | bin/ftpsync | 31 |
1 files 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 |