Files
proxmox/scripts/monitoring/send-alert.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

125 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Universal Alert Sender
# Sends alerts via configured channels
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
CONFIG_FILE="${PROJECT_ROOT}/smom-dbis-138/.env.alerts"
# Load configuration
if [ -f "$CONFIG_FILE" ]; then
source "$CONFIG_FILE"
fi
SEVERITY="${1:-WARNING}"
TITLE="${2:-Alert}"
MESSAGE="${3:-}"
send_email_alert() {
if [ "${ALERT_EMAIL_ENABLED:-false}" != "true" ]; then
return 0
fi
local to="${ALERT_EMAIL_TO:-}"
if [ -z "$to" ]; then
return 0
fi
echo "$MESSAGE" | mail -s "[$SEVERITY] $TITLE" "$to" 2>/dev/null || true
}
send_webhook_alert() {
local url="${1:-}"
if [ -z "$url" ] || [ "${ALERT_WEBHOOK_ENABLED:-false}" != "true" ]; then
return 0
fi
local payload=$(cat <<EOF
{
"severity": "$SEVERITY",
"title": "$TITLE",
"message": "$MESSAGE",
"timestamp": "$(date -Iseconds)"
}
EOF
)
curl -X POST "$url" \
-H "Content-Type: application/json" \
-d "$payload" \
2>/dev/null || true
}
send_slack_alert() {
if [ "${ALERT_SLACK_ENABLED:-false}" != "true" ]; then
return 0
fi
local webhook="${ALERT_SLACK_WEBHOOK_URL:-}"
if [ -z "$webhook" ]; then
return 0
fi
local color="warning"
case "$SEVERITY" in
CRITICAL|ERROR) color="danger" ;;
WARNING) color="warning" ;;
INFO) color="good" ;;
esac
local payload=$(cat <<EOF
{
"attachments": [{
"color": "$color",
"title": "$TITLE",
"text": "$MESSAGE",
"footer": "Blockchain Monitoring",
"ts": $(date +%s)
}]
}
EOF
)
curl -X POST "$webhook" \
-H "Content-Type: application/json" \
-d "$payload" \
2>/dev/null || true
}
send_discord_alert() {
if [ "${ALERT_DISCORD_ENABLED:-false}" != "true" ]; then
return 0
fi
local webhook="${ALERT_DISCORD_WEBHOOK_URL:-}"
if [ -z "$webhook" ]; then
return 0
fi
local payload=$(cat <<EOF
{
"embeds": [{
"title": "$TITLE",
"description": "$MESSAGE",
"color": $([ "$SEVERITY" = "CRITICAL" ] && echo "16711680" || echo "16776960"),
"timestamp": "$(date -Iseconds)"
}]
}
EOF
)
curl -X POST "$webhook" \
-H "Content-Type: application/json" \
-d "$payload" \
2>/dev/null || true
}
# Send alerts via all enabled channels
send_email_alert
send_webhook_alert "${ALERT_WEBHOOK_URL:-}"
send_slack_alert
send_discord_alert