35 lines
1.4 KiB
Bash
35 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|||
|
|
# Fleet health check: per-team container count vs registry enabled count,
|
||
|
|
# per-team receiver systemd state, and host disk. Read-only, safe to run any time.
|
||
|
|
set -uo pipefail
|
||
|
|
cd /opt/gemastik18-final/panel
|
||
|
|
|
||
|
|
EXPECTED=$(python3 -c "
|
||
|
|
import sys; sys.path.insert(0,'.')
|
||
|
|
import teams
|
||
|
|
print(len(teams.enabled_challenges()))
|
||
|
|
")
|
||
|
|
TEAMS=$(ls -d /opt/gemastik18-final/teams/team* 2>/dev/null | sed 's/.*team//' | sort -n)
|
||
|
|
echo "enabled challenges: $EXPECTED"
|
||
|
|
echo "teams: ${TEAMS:-none}"
|
||
|
|
echo
|
||
|
|
|
||
|
|
for i in $TEAMS; do
|
||
|
|
up=$(docker ps --format '{{.Names}}' | grep -c "_container_team${i}\$" || true)
|
||
|
|
all=$(docker ps -a --format '{{.Names}}' | grep -c "_container_team${i}\$" || true)
|
||
|
|
recv=$(systemctl is-active "gemastik-receiver-team${i}.service" 2>/dev/null || echo none)
|
||
|
|
label=$(python3 -c "import json;print(json.load(open('/opt/gemastik18-final/teams/team${i}/state.json'))['label'])" 2>/dev/null)
|
||
|
|
echo "team${i} (${label}) up=${up}/${EXPECTED} total_ctr=${all} receiver=${recv}"
|
||
|
|
if [ "$up" != "$EXPECTED" ]; then
|
||
|
|
echo " missing: $(python3 - <<PY
|
||
|
|
import sys; sys.path.insert(0,'.')
|
||
|
|
import json, subprocess, teams
|
||
|
|
want={c['name'] for c in teams.enabled_challenges()}
|
||
|
|
have={n.split('_container_team${i}')[0] for n in subprocess.run(['docker','ps','--format','{{.Names}}'],capture_output=True,text=True).stdout.split() if n.endswith('_container_team${i}')}
|
||
|
|
print(' '.join(sorted(want-have)) or '-')
|
||
|
|
PY
|
||
|
|
)"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
echo
|
||
|
|
df -h / | tail -1
|