ddd HANA backup monitoring

This commit is contained in:
2025-09-25 17:31:31 +02:00
parent 40c944adfe
commit 6c4ae73566
3 changed files with 34 additions and 2 deletions

View File

@@ -27,6 +27,8 @@ DISK_USAGE_THRESHOLD=80
TRUNCATED_PERCENTAGE_THRESHOLD=50
# Percentage of 'Free' log segments below which an alert is triggered
FREE_PERCENTAGE_THRESHOLD=25
# Maximum age of the last successful full data backup in hours.
BACKUP_THRESHOLD_HOURS=25
# --- Monitored Directories ---
# List of directories to check for disk usage (space-separated)

View File

@@ -1,5 +1,5 @@
#!/bin/bash
# Version: 1.0.5
# Version: 1.1.0
# =============================================================================
# SAP HANA Monitoring Script
#
@@ -123,5 +123,35 @@ if (( $(echo "$free_percentage < $FREE_PERCENTAGE_THRESHOLD" | bc -l) )); then
send_notification "HANA Log Segment Alert" "🚨 Alert: Only ${free_percentage}% of HANA log segments are in 'Free' state."
fi
echo " Checking last successful data backup status..."
# Query to get the start time of the most recent successful complete data backup
last_backup_date=$(hdbsql -U "$HANA_USERKEY" -j -a -x \
"SELECT TOP 1 SYS_START_TIME FROM M_BACKUP_CATALOG WHERE ENTRY_TYPE_NAME = 'complete data backup' AND STATE_NAME = 'successful' ORDER BY SYS_START_TIME DESC" 2>/dev/null | tr -d "\"" | sed 's/\..*//') # sed removes fractional seconds
if [[ -z "$last_backup_date" ]]; then
# No successful backup found at all
local message="🚨 Critical: No successful complete data backup found for ${COMPANY_NAME} HANA."
echo "$message"
send_notification "HANA Backup Alert" "$message"
return
fi
# Convert dates to epoch seconds for comparison
last_backup_epoch=$(date -d "$last_backup_date" +%s)
current_epoch=$(date +%s)
threshold_seconds=$((BACKUP_THRESHOLD_HOURS * 3600))
age_seconds=$((current_epoch - last_backup_epoch))
age_hours=$((age_seconds / 3600))
if (( age_seconds > threshold_seconds )); then
local message="🚨 Critical: Last successful HANA backup for ${COMPANY_NAME} is ${age_hours} hours old, which exceeds the threshold of ${BACKUP_THRESHOLD_HOURS} hours. Last backup was on: ${last_backup_date}."
echo "$message"
send_notification "HANA Backup Alert" "$message"
else
echo "✅ Success! Last successful backup is ${age_hours} hours old (Threshold: ${BACKUP_THRESHOLD_HOURS} hours)."
fi
echo "✅ Success! HANA monitoring check complete."