Skip to main content

max / mountaineer

762 B · 29 lines History Blame Raw
1 #!/bin/sh
2 # yambar `svc` segment feed: services health summary from sysop.
3 #
4 # Emits one yambar record per second:
5 # state|string|ok (all up)
6 # state|string|down (some down)
7 # count|string|<N> (count of down services, only on `down`)
8 #
9 # Routes operator into `sysop services` when state != ok.
10
11 set -eu
12
13 while :; do
14 summary="$(sysop services --summary 2>/dev/null || echo 'down')"
15 case "$summary" in
16 ok)
17 printf 'state|string|ok\n\n'
18 ;;
19 *' down')
20 count="${summary% down}"
21 printf 'state|string|down\ncount|string|%s\n\n' "$count"
22 ;;
23 *)
24 printf 'state|string|down\ncount|string|?\n\n'
25 ;;
26 esac
27 sleep 5
28 done
29