added timestamp validation for velero check
This commit is contained in:
parent
9be1895e48
commit
92493bc018
1 changed files with 20 additions and 0 deletions
|
@ -65,12 +65,32 @@ LATEST_PHASE=$(jq -r '
|
|||
| .status.phase
|
||||
' <<<"$VELERO_JSON")
|
||||
|
||||
###### Check logic below:
|
||||
|
||||
# CRITICAL if latest failed
|
||||
if [[ "$LATEST_PHASE" != "Completed" ]]; then
|
||||
echo "CRITICAL: latest backup '$LATEST_NAME' status = $LATEST_PHASE"
|
||||
exit $STATE_CRITICAL
|
||||
fi
|
||||
|
||||
# Get current timestamp
|
||||
timestamp=$(echo $LATEST_NAME | awk -F '-' '{print $3}')
|
||||
crit_days_old=3
|
||||
|
||||
# Convert to epoch
|
||||
timestamp_epoch=$(date -d "${timestamp:0:8} ${timestamp:8:2}:${timestamp:10:2}:${timestamp:12:2}" +%s)
|
||||
|
||||
# Get current epoch
|
||||
now_epoch=$(date +%s)
|
||||
|
||||
# Calculate age in days
|
||||
age_days=$(( (now_epoch - timestamp_epoch) / 86400 ))
|
||||
|
||||
# CRITICAL if latest is older than 3 days
|
||||
if (( age_days > crit_days_old )); then
|
||||
echo "CRITICAL: latest backup '$LATEST_NAME' is older than $days_old days ($age_days days old)"
|
||||
fi
|
||||
|
||||
# WARNING if any of the last 3 failed
|
||||
FAIL_LIST=$(jq -r '
|
||||
.items
|
||||
|
|
Loading…
Add table
Reference in a new issue