Files
weval-l99/tools/providers-health.sh
2026-04-15 01:38:46 +02:00

19 lines
533 B
Bash
Executable File

#!/bin/bash
CACHE=/tmp/sov-cache.json
# Refresh cache if older than 2 minutes
if [ ! -f "$CACHE" ] || [ $(( $(date +%s) - $(stat -c %Y "$CACHE") )) -gt 120 ]; then
curl -sf http://127.0.0.1:4000/health -o "$CACHE" --max-time 5 2>/dev/null
fi
if [ -f "$CACHE" ]; then
python3 -c "
import json
d=json.load(open('$CACHE'))
for p in d.get('providers',[]):
print(f' {p}: UP')
print(f'Active: {d.get(\"active\",0)}/{d.get(\"total\",0)}')
print(f'Primary: {d.get(\"primary\",\"?\")}')
" 2>/dev/null
else
echo "SOVEREIGN_DOWN"
fi