From d58b1ebf7ab48cd49ccb16a0247da9c359ffbca2 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Wed, 28 Aug 2024 17:12:33 +0200 Subject: [PATCH] check_clintstatus: update counter new/ changed/ deleted fileobjects without restic snapshot comparison --- check_clientbackup.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/check_clientbackup.sh b/check_clientbackup.sh index 73d5688..3b0e196 100755 --- a/check_clientbackup.sh +++ b/check_clientbackup.sh @@ -18,6 +18,7 @@ # 2022-10-20 ah v1.4 show last backup, prune and verify # 2023-09-01 ah v1.5 add counters for new/ changed/ deleted fileobjects (Restic only) # 2023-09-04 ah v1.6 fix perfdata dirs-del= +# 2024-08-28 ah v1.7 update counter new/ changed/ deleted fileobjects without restic snapshot comparison # ============================================================================== . $(dirname $0)/includes/jobhelper.sh @@ -154,16 +155,31 @@ else if cat $logfile | grep restic >/dev/null; then echo ">>> Counters:" - iModFNew=$( cat $logfile | grep -c "^+ /.*[^/]$" ) - iModDNew=$( cat $logfile | grep -c "^+ /.*/$" ) - iModFChange=$( cat $logfile | grep -c "^M /.*[^/]$" ) - iModDChange=$( cat $logfile | grep -c "^M /.*/$" ) - iModFDelete=$( cat $logfile | grep -c "^- /.*[^/]$" ) - iModDDelete=$( cat $logfile | grep -c "^- /.*/$" ) - - printf "__COUNTERS__New: %10s files %10s dirs\n" $iModFNew $iModDNew - printf "__COUNTERS__Changed: %10s files %10s dirs\n" $iModFChange $iModDChange - printf "__COUNTERS__Deleted: %10s files %10s dirs\n" $iModFDelete $iModDDelete + + # This is faster andd doesn't need comparison of snapshots in output + # and works with initial backups too + iModFNew=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$2;} END {print sum;}' ) + iModFChange=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$4;} END {print sum;}' ) + iModFNone=$( cat $logfile | grep "^Files:.*unmodified" | awk '{sum+=$6;} END {print sum;}' ) + iModFDelete=$( cat $logfile | grep "^Files:.*removed" | awk '{sum+=$4;} END {print sum;}' ) + + iModDNew=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$2;} END {print sum;}' ) + iModDChange=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$4;} END {print sum;}' ) + iModDNone=$( cat $logfile | grep "^Dirs:.*unmodified" | awk '{sum+=$6;} END {print sum;}' ) + iModDDelete=$( cat $logfile | grep "^Dirs:.*removed" | awk '{sum+=$4;} END {print sum;}' ) + + # old way: + # iModFNew=$( cat $logfile | grep -c "^+ /.*[^/]$" ) + # iModDNew=$( cat $logfile | grep -c "^+ /.*/$" ) + # iModFChange=$( cat $logfile | grep -c "^M /.*[^/]$" ) + # iModDChange=$( cat $logfile | grep -c "^M /.*/$" ) + # iModFDelete=$( cat $logfile | grep -c "^- /.*[^/]$" ) + # iModDDelete=$( cat $logfile | grep -c "^- /.*/$" ) + + printf "__COUNTERS__New: %10s files %10s dirs\n" $iModFNew $iModDNew + printf "__COUNTERS__Changed: %10s files %10s dirs\n" $iModFChange $iModDChange + printf "__COUNTERS__Deleted: %10s files %10s dirs\n" $iModFDelete $iModDDelete + printf "__COUNTERS__Unchanged: %10s files %10s dirs\n" $iModFNone $iModDNone echo "__PERFDATA__ |files-new=$iModFNew;;;0 files-mod=$iModFChange;;;0 files-del=$iModFDelete dirs-new=$iModDNew;;;0 dirs-mod=$iModDChange;;;0 dirs-del=$iModDDelete;;;0" echo fi -- GitLab