Skip to content

Socket protocol

polso listens on ~/.config/polso/sock (change it with socket in the config). The socket is mode 600, so only your user can write to it. No ports, no auth, no HTTP.

  • Send one JSON message per line. A line can also be a JSON array (a batch).
  • Each line gets exactly one reply line: ok or error: <why>.
  • Keep the connection open and stream, or connect per message. Both work.
Terminal window
$ echo '{"type":"value","slot":"left","value":42}' | nc -U ~/.config/polso/sock
ok
$ echo '{"type":"value","slot":"middle","value":42}' | nc -U ~/.config/polso/sock
error: value: slot must be "left" or "right"

Feeds a wing.

field type
slot "left" | "right" required
value number appended to the history
values number[] replaces the whole history (backfill a sparkline in one go)
label string text shown instead of the formatted number (gauge, panel)
health ok | warn | crit | unknown overrides the threshold-based color

At least one of value, values, label, health is needed. type can be omitted when value or values is present. A message with a number resets label and health. A message with only label or health patches them and leaves the history alone.

{"type":"value","slot":"left","value":42}
{"slot":"right","values":[3,4,8,6,5]}
{"type":"value","slot":"right","value":3,"label":"3 jobs","health":"warn"}
{"type":"value","slot":"right","health":"crit"}
field type
slot "left" | "right" optional, omitted = whole notch
color string ok warn crit info, red orange yellow green mint teal cyan blue indigo purple pink white, or #rgb/#rrggbb. Default: ping.color (crit)
{"type":"ping"}
{"type":"ping","slot":"left","color":"#ff4433"}
field type
title string required
summary string second line
severity info | warn | crit default crit
count integer starts the ×N counter
url string opened when the alert is clicked in the panel log
{"type":"alert","title":"Deploy failed","summary":"api-gateway · rollout stuck","severity":"crit","url":"https://ci.example.com/runs/812"}
[{"type":"value","slot":"left","value":9.1},{"type":"ping","slot":"left"},{"type":"alert","title":"Load spike","severity":"warn"}]

A batch is validated as a whole, then applied in order, with a single ok. Numeric strings count as numbers ("value":"42"), since shell senders tend to quote everything.

Terminal window
sock=~/.config/polso/sock
polso() { printf '%s\n' "$1" | nc -U "$sock"; }
polso '{"type":"value","slot":"left","value":'"$(sysctl -n vm.loadavg | awk '{print $2}')"'}'
# long-running: one connection, many lines
while sleep 1; do echo "{\"slot\":\"left\",\"value\":$RANDOM}"; done | nc -U "$sock"