Files
proxmox/scripts/monitoring/alert-block-stall.sh

47 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Block Production Stall Alert
# Load alert configuration
if [ -f "$SCRIPT_DIR/../smom-dbis-138/.env.alerts" ]; then
source "$SCRIPT_DIR/../smom-dbis-138/.env.alerts"
fi
# Sends alerts when block production stalls
set -euo pipefail
BLOCK=$1
STALL_TIME=$2
# Alert channels (configure as needed)
ALERT_EMAIL="${ALERT_EMAIL:-}"
ALERT_WEBHOOK="${ALERT_WEBHOOK:-}"
log_error() { echo "[ALERT] $1" >&2; }
send_alert() {
local message="$1"
log_error "BLOCK PRODUCTION STALLED: $message"
# Email alert
if [ -n "$ALERT_EMAIL" ]; then
echo "$message" | mail -s "BLOCK PRODUCTION STALLED" "$ALERT_EMAIL" 2>/dev/null || true
fi
# Webhook alert
if [ -n "$ALERT_WEBHOOK" ]; then
curl -X POST "$ALERT_WEBHOOK" \
-H "Content-Type: application/json" \
-d "{\"text\":\"$message\"}" 2>/dev/null || true
fi
# Log to file
echo "$(date): $message" >> /var/log/block-stall-alerts.log
}
main() {
local message="Block production stalled at block $BLOCK for ${STALL_TIME} seconds"
send_alert "$message"
}
main "$@"