diff --git a/storage_helper.sh b/storage_helper.sh index e90e2c8689f3107c396ce76423c44c53a28859b3..ca19827e101ac9fe997585e74f6d8368be34124a 100755 --- a/storage_helper.sh +++ b/storage_helper.sh @@ -30,6 +30,7 @@ # 2021-06-16 hahn added backupstatus # 2021-06-18 hahn store backup status in status files ... do not grep frpom logs # 2021-06-21 hahn use single status file; added backup size +# 2021-01-22 hahn show inactive backups in status page; colored lines by status # ====================================================================== # ---------------------------------------------------------------------- @@ -72,6 +73,12 @@ ;; "error") sColorcode="91" # red ;; + "warn") sColorcode="33" # yellow + ;; + "active") sColorcode="94" # light blue + ;; + "disabled") sColorcode="90" # gray + ;; esac if [ ! -z ${sColorcode} ]; then echo -ne "\e[${sColorcode}m" @@ -174,7 +181,18 @@ test -f "$sTouchfile" && echo 1 test -f "$sTouchfile" || echo 0 } - + # check if a backup for current server is running + # it returns 0 for no and 1 for yes + # global string sBackupClient FQDN of current server + # global string sBackupBasedir backup directory + function _isInactive(){ + ls ${sBackupBasedir}/*/$sBackupClient/inactive.txt >/dev/null 2>/dev/null + if [ $? -eq 0 ]; then + echo 1 + else + echo 0 + fi + } # ------------------------------------------------------------ # slot handling @@ -253,6 +271,7 @@ # test -r "$sStatusDir/${sBackupClient}" && . "$sStatusDir/${sBackupClient}" } + # list repositories ... used in setactive/ setinactive function _listRepodirs(){ for mydir in $( ls -1d ${sBackupBasedir}/*/* | grep -vE '(_active|somethinglsetodisable)' ) do @@ -271,13 +290,13 @@ function PUBLIC_backupstatus(){ typeset -i local ierrors=0 - local tbl="%-45s | %-20s | %-20s | %8s | %3s | %7s | %s \n" + local tbl="%s %-45s | %-20s | %-20s | %8s | %3s | %7s | %s \n" _showConnectionCount echo echo "This table shows the time and duration [s] of the last backup for each server." echo - printf "$tbl" " server" "start" "end" "duration" "rc" "age [h]" "size" + printf "$tbl" " " "server" "start" "end" "duration" "rc" "age [h]" "size" echo "-----------------------------------------------------------------------------------------------------------------------------" for myserver in $( _getLoggedServers ) do @@ -286,6 +305,7 @@ typeset -i local istart="$( _getLastBackupstart )" typeset -i local iend="$( _getLastBackupend )" typeset -i local bIsRunning=$( _isRunning ) + typeset -i local bIsInactive=$( _isInactive ) typeset -i local iLastStatus=$( _getLastBackupstatus ) local size=$( _getBackupsize ) @@ -295,21 +315,34 @@ typeset -i local iage=$( date +%s )-${iend} typeset -i local iagehours=$iage/60/60 - # check values - if [ $iagehours -gt $iMaxbackupAge ]; then - ierrors=$ierrors+1 - fi - local sduration=$iduration test $iduration -lt 0 && sduration="RUNNING" - sStatusRun="." - test $iend -eq 0 && sStatusRun="?" - test $bIsRunning -eq 1 && sStatusRun="R" + sStatusRun="$(color ok)." + test $iend -eq 0 && sStatusRun="$(color warn)?" + test $bIsRunning -eq 1 && sStatusRun="$(color active)R" + test $bIsInactive -eq 1 && sStatusRun="$(color disabled)D" + # check values + if [ $iend -gt 0 -a $iagehours -gt $iMaxbackupAge -a $bIsInactive -eq 0 ]; then + ierrors=$ierrors+1 + sStatusRun="$(color error)E" + fi + + if [ $iend -eq 0 ]; then + tstart="-" + tend="-" + sduration="" + iagehours="" + fi + # output - printf "$tbl" "$sStatusRun $myserver" "${tstart}" "${tend}" "${sduration}" "$iLastStatus" "${iagehours}" "$size" + printf "$tbl" "$sStatusRun" "$myserver" "${tstart}" "${tend}" "${sduration}" "$iLastStatus" "${iagehours}" "$size" done + color reset + echo + echo "Legend" + echo ". OK | ? not started | R running | D disabled | E error" echo echo "total : $( _getLoggedServers | wc -l ) servers" echo "errors: $ierrors"