Fix zulip-monitor.sh: Remove email spam, use Zulip #agent-hub only #57
+28
-31
@@ -9,10 +9,11 @@ ZULIP_EMAIL="abiba-bot@chat.sysloggh.net"
|
|||||||
ZULIP_KEY="cKTDMZAPW08dk3zl05sStzO7HRztzyn8"
|
ZULIP_KEY="cKTDMZAPW08dk3zl05sStzO7HRztzyn8"
|
||||||
OWNER_ZULIP_ID="9"
|
OWNER_ZULIP_ID="9"
|
||||||
|
|
||||||
# Email config
|
|
||||||
GMAIL_USER="jtabiri@gmail.com"
|
LOG="/root/zulip-health-monitor.log"
|
||||||
GMAIL_PASS="rgbuomwcydxwbszd"
|
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M UTC')
|
||||||
EMAIL_TO="jerome@sysloggh.com"
|
ISSUES=0
|
||||||
|
echo "=== Zulip Health Check — $TIMESTAMP ===" >> "$LOG"
|
||||||
|
|
||||||
notify() {
|
notify() {
|
||||||
local severity="$1" msg="$2"
|
local severity="$1" msg="$2"
|
||||||
@@ -24,30 +25,14 @@ notify() {
|
|||||||
curl -sf -X POST "${ZULIP_SITE}/api/v1/messages" \
|
curl -sf -X POST "${ZULIP_SITE}/api/v1/messages" \
|
||||||
-u "${ZULIP_EMAIL}:${ZULIP_KEY}" \
|
-u "${ZULIP_EMAIL}:${ZULIP_KEY}" \
|
||||||
-d "${form}" > /dev/null 2>&1 || true
|
-d "${form}" > /dev/null 2>&1 || true
|
||||||
|
# Zulip stream post to #agent-hub on topic 'zulip-health'
|
||||||
# Email alert
|
local stream_content="${severity} Zulip Monitor: ${msg}"
|
||||||
local subject="${severity} Zulip Monitor Alert"
|
curl -sf -X POST "${ZULIP_SITE}/api/v1/messages" \
|
||||||
python3 -c "
|
-u "${ZULIP_EMAIL}:${ZULIP_KEY}" \
|
||||||
import smtplib
|
-d "type=stream\&to=%5B7%5D\&topic=zulip-health\&content=$(python3 -c "import urllib.parse; print(urllib.parse.quote(str()))")" \
|
||||||
from email.mime.text import MIMEText
|
> /dev/null 2>&1 || true
|
||||||
m = MIMEText('''${msg}''')
|
|
||||||
m['From'] = 'abiba@sysloggh.com'
|
|
||||||
m['To'] = '${EMAIL_TO}'
|
|
||||||
m['Subject'] = '${subject}'
|
|
||||||
s = smtplib.SMTP('smtp.gmail.com', 587)
|
|
||||||
s.starttls()
|
|
||||||
s.login('${GMAIL_USER}', '${GMAIL_PASS}')
|
|
||||||
s.sendmail('abiba@sysloggh.com', ['${EMAIL_TO}'], m.as_string())
|
|
||||||
s.quit()
|
|
||||||
" 2>/dev/null || true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMESTAMP=$(date -u '+%Y-%m-%d %H:%M UTC')
|
|
||||||
ISSUES=0
|
|
||||||
LOG="/root/zulip-health-monitor.log"
|
|
||||||
|
|
||||||
echo "=== Zulip Health Check — $TIMESTAMP ===" >> "$LOG"
|
|
||||||
|
|
||||||
# ── Global: Zulip Server ──
|
# ── Global: Zulip Server ──
|
||||||
SERVER_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 10 \
|
SERVER_CODE=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 10 \
|
||||||
https://chat.sysloggh.net/api/v1/server_settings \
|
https://chat.sysloggh.net/api/v1/server_settings \
|
||||||
@@ -81,11 +66,23 @@ else
|
|||||||
echo " Abiba: ✅ Connected (processed=$(echo "$PI_HEALTH" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('messages_processed',0))" 2>/dev/null))" >> "$LOG"
|
echo " Abiba: ✅ Connected (processed=$(echo "$PI_HEALTH" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('messages_processed',0))" 2>/dev/null))" >> "$LOG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── Platform B: Tanko (DSH) ──
|
# ── Platform B: Hermes (Tanko) ──
|
||||||
# Tanko moved to DSH (DeepSeek Harness) on 2026-08-27. It no longer runs a Hermes
|
TANKO_STATE=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 jerome@192.168.68.122 \
|
||||||
# gateway, so there is no ~/.hermes/gateway_state.json on CT 112 (.122) to probe.
|
"cat ~/.hermes/gateway_state.json 2>/dev/null" 2>/dev/null || echo "{}")
|
||||||
# Zulip connectivity for tanko is managed by the DSH harness; skip the legacy SSH probe.
|
TANKO_ZULIP=$(echo "$TANKO_STATE" | python3 -c "
|
||||||
echo " Tanko: ⏭️ skipped (DSH — no Hermes gateway since 2026-08-27)" >> "$LOG"
|
import sys,json
|
||||||
|
d=json.load(sys.stdin)
|
||||||
|
p=d.get('platforms',{}).get('zulip',{})
|
||||||
|
print(p.get('state','unknown'))
|
||||||
|
" 2>/dev/null)
|
||||||
|
|
||||||
|
if [ "$TANKO_ZULIP" != "connected" ]; then
|
||||||
|
notify "🔴" "Tanko (Hermes) Zulip state: $TANKO_ZULIP — needs restart"
|
||||||
|
ISSUES=$((ISSUES + 1))
|
||||||
|
echo " Tanko: ❌ state=$TANKO_ZULIP" >> "$LOG"
|
||||||
|
else
|
||||||
|
echo " Tanko: ✅ Zulip connected" >> "$LOG"
|
||||||
|
fi
|
||||||
|
|
||||||
# ── Platform B: Hermes (Mumuni) ──
|
# ── Platform B: Hermes (Mumuni) ──
|
||||||
MUMUNI_STATE=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@192.168.68.24 \
|
MUMUNI_STATE=$(ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@192.168.68.24 \
|
||||||
|
|||||||
Reference in New Issue
Block a user