Files
AI-Profile-Router/platform/checks/verify-platform.sh
T

108 lines
3.6 KiB
Bash
Executable File

#!/usr/bin/env bash
set -uo pipefail
PASS=0
WARN=0
FAIL=0
pass() { printf 'PASS %s\n' "$*"; PASS=$((PASS + 1)); }
warn() { printf 'WARN %s\n' "$*"; WARN=$((WARN + 1)); }
fail() { printf 'FAIL %s\n' "$*"; FAIL=$((FAIL + 1)); }
echo "== Local AI platform verification =="
ROOT_USE="$(df -P / | awk 'NR==2 {gsub(/%/, "", $5); print $5}')"
if [[ -n "$ROOT_USE" && "$ROOT_USE" -lt 85 ]]; then
pass "Systempartition bei ${ROOT_USE}%"
else
fail "Systempartition bei ${ROOT_USE:-unbekannt}% (Ziel: unter 85%)"
fi
if command -v nvidia-smi >/dev/null 2>&1; then
GPU_LIST="$(nvidia-smi --query-gpu=name,memory.total --format=csv,noheader 2>/dev/null)"
GPU_COUNT="$(printf '%s\n' "$GPU_LIST" | sed '/^[[:space:]]*$/d' | wc -l)"
if [[ "$GPU_COUNT" -ge 2 ]]; then
pass "beide GPUs erkannt: $(printf '%s' "$GPU_LIST" | paste -sd ' | ' -)"
elif [[ "$GPU_COUNT" -eq 1 ]]; then
fail "nur eine von zwei erwarteten GPUs erkannt: $GPU_LIST"
else
fail "nvidia-smi liefert keine GPU"
fi
else
fail "nvidia-smi fehlt"
fi
if [[ -e /sys/class/net/lan0 ]] && \
[[ "$(< /sys/class/net/lan0/address)" == "58:11:22:bb:ad:0c" ]] && \
[[ "$(< /sys/class/net/lan0/operstate)" == "up" ]]; then
pass "stabiles LAN-Interface lan0 aktiv (58:11:22:bb:ad:0c)"
else
fail "stabiles LAN-Interface lan0 fehlt, ist down oder hat die falsche MAC"
fi
container_healthy() {
local name=$1 state health
state="$(docker inspect --format '{{.State.Status}}' "$name" 2>/dev/null || true)"
health="$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$name" 2>/dev/null || true)"
[[ $state == running && ( -z $health || $health == healthy ) ]]
}
for container in mike-ai-profile-controller mike-ai-router mike-ai-xtts \
mike-ai-piper mike-ai-tts-gateway mike-ai-open-webui; do
if container_healthy "$container"; then
pass "$container gesund"
else
fail "$container fehlt oder ist nicht gesund"
fi
done
ACTIVE_LLAMA="$(docker ps --format '{{.Names}}' | grep -Ec '^mike-ai-llama-(fast|medium|large|ultra|uncensored|experimental)$' || true)"
if [[ $ACTIVE_LLAMA -eq 1 ]]; then
pass "exakt ein llama.cpp-Profil aktiv"
else
fail "$ACTIVE_LLAMA llama.cpp-Profile aktiv (erwartet: 1)"
fi
for optional in mike-ai-mcp-web mike-ai-mcp-homeassistant mike-ai-mcp-arr \
mike-ai-mcp-github mike-ai-mcp-platform-context mike-ai-mcp-unraid-official; do
if container_healthy "$optional"; then
pass "$optional aktiv"
else
warn "$optional nicht aktiv oder nicht installiert"
fi
done
if [[ -s /var/lib/mike-ai-platform-context/runtime.json ]]; then
snapshot_age=$(( $(date +%s) - $(stat -c %Y /var/lib/mike-ai-platform-context/runtime.json) ))
if (( snapshot_age <= 180 )); then
pass "Platform-Kontext-Snapshot aktuell (${snapshot_age}s)"
else
fail "Platform-Kontext-Snapshot veraltet (${snapshot_age}s)"
fi
else
fail "Platform-Kontext-Snapshot fehlt"
fi
if docker exec mike-ai-router python -c \
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8081/health', timeout=3)" \
>/dev/null 2>&1; then
pass "Router-Liveness intern erreichbar"
else
fail "Router-Liveness intern nicht erreichbar"
fi
if systemctl list-unit-files --no-legend 2>/dev/null | grep -Eq '(vision-rx|whisper-rx|granite-rx).*enabled'; then
warn "Aktivierte RX-Altlast gefunden"
else
pass "Keine aktivierte RX-Altlast"
fi
if systemctl list-unit-files --no-legend 2>/dev/null | grep -E '(benchmark|race).*enabled' >/dev/null; then
warn "Automatisch aktivierter Benchmark-/Race-Dienst gefunden"
else
pass "Keine automatisch aktivierten Benchmarks"
fi
printf '\nErgebnis: %d PASS, %d WARN, %d FAIL\n' "$PASS" "$WARN" "$FAIL"
[[ "$FAIL" -eq 0 ]]