Files
hana-scripts/hana.conf
Tomi Eckert 8e0ba1878f refactor(cleanup): generalize cleanup beyond logs
Rename configuration variables and functions to reflect broader
functionality beyond just log files. Updates include renaming
LOG_DIRS_FOR_CLEANUP to DIRS_FOR_AUTODELETE and
clean_log_files to clean_directory_files. Adds safety warnings
to prevent deletion of critical HANA system logs.

BREAKING CHANGE: Config keys renamed from LOG_DIRS_FOR_CLEANUP to
DIRS_FOR_AUTODELETE and MAX_LOG_FILE_AGE_DAYS to MAX_FILE_AGE_DAYS
2026-03-12 20:49:37 +01:00

77 lines
2.2 KiB
Bash

#!/bin/bash
# =============================================================================
# SAP HANA Common Configuration
# =============================================================================
# --- HANA Instance Configuration ---
# HANA SID (e.g., "NDB") - used to derive the HANA user (<sid>adm)
HANA_SID="NDB"
# Derived HANA Linux user (automatically computed from HANA_SID)
HANA_USER="$(echo "$HANA_SID" | tr '[:upper:]' '[:lower:]')adm"
# HANA Instance Number (e.g., "00")
HANA_INSTANCE_NR="00"
# HANA User Key for hdbsql (hdbuserstore key)
HANA_USER_KEY="CRONKEY"
# --- Paths ---
SAPCONTROL_PATH="/usr/sap/hostctrl/exe/sapcontrol"
HDBSQL_PATH="/usr/sap/HDB/HDB${HANA_INSTANCE_NR}/exe/hdbsql"
# --- Monitoring Directories ---
DIRECTORIES_TO_MONITOR=(
"/hana/shared"
"/hana/log"
"/hana/data"
"/usr/sap"
)
# --- Directories for Auto-Delete ---
# These directories will be automatically cleaned when disk space is low
# Format: "mount_point:directory_path"
# The script will check if a monitored directory is on the same mount point
# as an auto-delete directory and can clean it to free up space
# NOTE: Do NOT include HANA system logs like /hana/log - only include
# directories with safe-to-delete files like backup logs, temp files, etc.
DIRS_FOR_AUTODELETE=(
"/hana/log:/hana/log/backups"
"/hana/data:/hana/data/temp"
"/usr/sap:/usr/sap/trans/log"
"/usr/sap:/usr/sap/hostctrl/work/log"
)
# --- Disk Auto-Delete Configuration ---
# Minimum free space percentage to maintain after cleanup
MIN_FREE_SPACE_AFTER_CLEANUP=5
# Maximum age of files to delete (in days)
MAX_FILE_AGE_DAYS=7
# Enable automatic cleanup when disk usage exceeds threshold
AUTO_CLEANUP_ENABLED=true
# --- Thresholds ---
DISK_USAGE_THRESHOLD=85
TRUNCATED_PERCENTAGE_THRESHOLD=50
FREE_PERCENTAGE_THRESHOLD=10
STATEMENT_QUEUE_THRESHOLD=10
STATEMENT_QUEUE_CONSECUTIVE_RUNS=3
BACKUP_THRESHOLD_HOURS=32
# --- Notification Configuration ---
NTFY_TOKEN=""
NTFY_TOPIC_URL=""
COMPANY_NAME="My Company"
# --- Logging Configuration ---
LOG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
LOG_FILE="${LOG_DIR}/hana_monitor.log"
# --- State Directory ---
STATE_DIR="${LOG_DIR}/monitor_state"
mkdir -p "${STATE_DIR}"
# --- Lock Directory ---
LOCK_DIR="/tmp"