33 lines
1.4 KiB
Bash
33 lines
1.4 KiB
Bash
|
|
#!/bin/sh
|
||
|
|
# xfce4-genmon panel indicator — polls colibri daemon health.
|
||
|
|
# Install: add a Generic Monitor panel item pointing to this script.
|
||
|
|
# Refresh interval: 30s.
|
||
|
|
#
|
||
|
|
# Output: green/red dot + agent count + task count.
|
||
|
|
# 🟢 2 agents · 3 tasks
|
||
|
|
# 🔴 daemon down
|
||
|
|
|
||
|
|
SOCKET="${COLIBRI_SOCKET:-/var/run/colibri/colibri.sock}"
|
||
|
|
TOOLTIP=""
|
||
|
|
|
||
|
|
if [ -S "$SOCKET" ]; then
|
||
|
|
STATUS=$(printf '{"cmd":"status"}\n' | nc -U "$SOCKET" -w 2 2>/dev/null)
|
||
|
|
if [ -n "$STATUS" ]; then
|
||
|
|
AGENTS=$(echo "$STATUS" | python3 -c "import sys,json; d=json.load(sys.stdin)['data']; print(d['agents'])" 2>/dev/null)
|
||
|
|
TASKS=$(echo "$STATUS" | python3 -c "import sys,json; d=json.load(sys.stdin)['data']; t=d['tasks']; print(t['started'])" 2>/dev/null)
|
||
|
|
HOST=$(echo "$STATUS" | python3 -c "import sys,json; print(json.load(sys.stdin)['data']['host'])" 2>/dev/null)
|
||
|
|
|
||
|
|
echo "<txt>🟢 ${AGENTS} agents · ${TASKS} tasks</txt>"
|
||
|
|
TOOLTIP="Colibri: ${HOST} | socket: ${SOCKET} | agents: ${AGENTS} | started tasks: ${TASKS}"
|
||
|
|
else
|
||
|
|
echo "<txt>🔴 no response</txt>"
|
||
|
|
TOOLTIP="Colibri socket exists but not responding"
|
||
|
|
fi
|
||
|
|
else
|
||
|
|
echo "<txt>🔴 down</txt>"
|
||
|
|
TOOLTIP="Colibri daemon not running (no socket at ${SOCKET})"
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "<tool>${TOOLTIP}</tool>"
|
||
|
|
echo "<txtclick>xfce4-terminal --title 'Colibri Status' --command 'colibri status'</txtclick>"
|