diff options
Diffstat (limited to 'genesis_agg1.sh')
-rwxr-xr-x | genesis_agg1.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/genesis_agg1.sh b/genesis_agg1.sh new file mode 100755 index 0000000..4bb31aa --- /dev/null +++ b/genesis_agg1.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# === Config === +declare -A NODES=( + [genesis-west]="root@172.232.172.119" + [genesis-east]="root@198.74.58.14" + [genesis-midwest]="root@45.56.126.90" +) + +TELEGRAM_BOT_TOKEN="7277705363:AAGSw5Pmcbf7IsSyZKMqU6PJ4VsVwdKLRH0" +TELEGRAM_CHAT_ID="1559582356" + +# === Functions === + +send_telegram() { + local msg="$1" + curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ + -d chat_id="${TELEGRAM_CHAT_ID}" \ + -d text="$msg" \ + -d parse_mode="Markdown" +} + +# === Main === + +alert_text="*GenesisRouteWatch Alert!*\n" +issue_found=0 + +for region in "${!NODES[@]}"; do + host="${NODES[$region]}" + echo "🌐 Probing $region ($host)..." + output=$(ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no $host "/root/genesis_routewatch.sh" 2>/dev/null) + + echo "🛰️ $region Output:" + echo "$output" + echo + + # Save raw report + full_report+="🛰️ *$region*:\n\`\`\`\n$output\n\`\`\`\n\n" + + # Detect issues + if echo "$output" | grep -q "Status: CRITICAL"; then + alert_text+="$region* path degraded!\n" + issue_found=1 + fi +done + +# Send alert only if something's wrong +if [[ $issue_found -eq 1 ]]; then + send_telegram "$alert_text" +else + echo "✅ All paths healthy. No alert sent." +fi |