Files
openclaw/tools/jarvis-health-check.sh
Clawd Bot ca9b510922 chore: align with upstream openclaw/openclaw and overlay local additions
- Reset master to upstream/main (16,697 commits)
- Overlay 2,271 local-only files (skills, tools, workspace, configs, apps)
- Restore IDENTITY.md and USER.md templates
- Build verified, gateway running, Discord working

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 07:40:46 +01:00

91 lines
2.7 KiB
Bash

#!/bin/bash
# JARVIS Smart Auto-Fix Health Check
# Fix automatically, only alert if CANNOT fix AND hasn't alerted in last hour
source /home/alex/clawd/tools/jarvis-smart-alert.sh
RED='\033[0;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
NC='\033[0m'
SILENT_LOG="/home/alex/clawd/logs/jarvis-silent-fixes.log"
log_fix() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$SILENT_LOG"
}
PROBLEMS_FOUND=0
PROBLEMS_FIXED=0
# Gateway check
if ! curl -sfk --connect-timeout 3 https://192.168.1.220:18789/ >/dev/null 2>&1; then
((PROBLEMS_FOUND++))
log_fix "Gateway down - attempting auto-fix"
# Try to fix
if systemctl is-active --quiet openclaw-gateway.service; then
sudo systemctl restart openclaw-gateway.service
else
sudo systemctl start openclaw-gateway.service
fi
sleep 5
# Verify fix
if curl -sfk --connect-timeout 3 https://192.168.1.220:18789/ >/dev/null 2>&1; then
log_fix "✅ Gateway auto-fixed"
((PROBLEMS_FIXED++))
else
# Cannot fix - use smart alert (only if >1 hour since last)
alert_critical "gateway_down" "Gateway CANNOT be auto-fixed - manual intervention required"
fi
fi
# Kanban check
if ! curl -sf --connect-timeout 3 http://192.168.1.220:5003/api/tasks?limit=1 >/dev/null 2>&1; then
((PROBLEMS_FOUND++))
log_fix "Kanban down - attempting auto-fix"
# Try to fix
if systemctl is-active --quiet kanban-board.service; then
sudo systemctl restart kanban-board.service
else
sudo systemctl start kanban-board.service
fi
sleep 5
# Verify fix
if curl -sf --connect-timeout 3 http://192.168.1.220:5003/api/tasks?limit=1 >/dev/null 2>&1; then
log_fix "✅ Kanban auto-fixed"
((PROBLEMS_FIXED++))
else
# Cannot fix - use smart alert
alert_critical "kanban_down" "Kanban CANNOT be auto-fixed - check service logs"
fi
fi
# MariaDB check (Synology - read-only, cannot auto-fix)
if [[ -f /etc/openclaw/mariadb.conf ]]; then
source /etc/openclaw/mariadb.conf
if ! mysql -h "$MARIADB_HOST" -P "$MARIADB_PORT" -u "$KANBAN_USER" -p"$KANBAN_PASS" "$KANBAN_DB" -e "$HEALTH_CHECK_QUERY" &>/dev/null; then
# External service - cannot fix, use smart alert
alert_critical "mariadb_synology_down" "MariaDB (Synology) unreachable - check NAS at $MARIADB_HOST"
fi
fi
# Log silent fixes
if [[ $PROBLEMS_FIXED -gt 0 ]]; then
log_fix "Auto-fixed $PROBLEMS_FIXED issues silently"
fi
# Exit 0 (success) - errors are handled via smart alerts
exit 0
# Pi disk auto-cleanup (silent, no alerts)
if [ -f /home/alex/clawd/tools/pi-disk-autoclean.sh ]; then
/home/alex/clawd/tools/pi-disk-autoclean.sh &>/dev/null &
fi