In scripts and pipes
Given a subcommand, ergo-aeron prints and exits instead of opening the
screen. Each tab has one, from the same table the screen uses, plus health
and snapshot:
Read an Aeron media driver's counters, streams, errors and loss without a client, or join a stream through a guarded embedded driver: a front-end-free core, a command line and a terminal UI (ergo-aeron)
Usage: ergo-aeron [OPTIONS] [COMMAND]
Commands:
counters Every counter: value, change per second (with --watch) and label (`AeronStat`)
streams One row per stream: positions, backlog, slowest subscriber, headroom
errors The driver's distinct errors (`ErrorStat`)
loss The driver's loss report (`LossStat`)
driver Pid, versions, buffer lengths and heartbeat age (`DriverTool`)
log A stream's log file as it lies: metadata, term tails and every frame header (`LogInspector`)
messages One stream's messages, read from its log file with no subscription (the publisher cannot notice), decoded with --schema. Starts with what the driver still keeps. With --embedded --channel: joined as a guarded receiver through the tool's own driver instead
recordings The recordings an archive lists on its control session (needs --control): positions, start and stop, stream, session, channel
recording One recording's descriptor and its four positions (needs --control)
recording-lag Each active recording's lag behind its stream (C4), from the archive's driver's counters only: no archive session, no client
replay One recording's messages, replayed to this tool through the control session (needs --control) and decoded with --schema: what it holds now, or with --follow also what is recorded next. The archive sends it on the control response channel; nothing it holds changes
archive-dir An archive directory read as files, never written (needs --archive-dir): `ArchiveTool`'s read commands. With no action, the catalogue header, the mark file and every entry
history The directories, streams, channels and schema sources used before, newest first; `history clear` forgets them
health One verdict from two reads; exit status 1 when it is ALARM
snapshot Everything as one JSON document, for a support bundle
help Print this message or the help of the given subcommand(s)
Options:
--aeron-dir <AERON_DIR> The driver's aeron directory (default: `AERON_DIR`, else Aeron's default)
--format <FORMAT> Output format (default: table on a terminal, json in a pipe) [possible values: table, json, compact, pretty, raw]
--watch <SECONDS> Print again every this many seconds, with rates, until interrupted (not `health`)
--schema <FILE|DIR|URL> An SBE schema for the Messages tab: a file, a directory of `*.xml`, or an HTTPS URL (with the `http` feature). Repeat for more
--interpret Show what the decoded values mean, beside the raw value: a timestamp as a date, a price as a decimal. A guess is marked with a `?`. The terminal UI shows them without it (`i` hides them)
--converters <FILE> A converters file: the rules that say what a value means (TOML). It asks for the interpretation too. The environment variable `ERGO_AERON_CONVERTERS` names one when this is not given
--interval <MS> Terminal UI: milliseconds between reads [default: 1000]
--no-mouse Terminal UI: start without capturing the mouse, so the terminal selects text (`M` turns capture on and off while running)
--stream <STREAM_ID> Terminal UI: open on this stream's messages
--session <SESSION_ID> Terminal UI: with --stream, this session of it
--channel <URI> Terminal UI, embedded mode: join --stream on this channel URI
--embedded Start a media driver of the tool's own, in a new directory removed on exit, to join streams named by --channel as a receiver (never started silently). Its stats tabs show that driver unless --aeron-dir names another
--embedded-dir <DIR> Embedded mode: the new directory for its driver; must not exist (default: a fresh one beside Aeron's default directory)
--no-history Read and write no history (directories, streams, channels and schema sources used before)
--color <COLOR> Colour and icons on tables and `health`, never on json (`auto`: a terminal, off with `NO_COLOR`, on with `CLICOLOR_FORCE`; `never` is plain) [default: auto] [possible values: auto, always, never]
--icons <ICONS> Icon set (`auto`: `ERGO_AERON_ICONS`, else the locale, fonts and terminal; a Nerd Font installed is not one in use, so then pick `emoji`) [default: auto] [possible values: auto, nerd, emoji, unicode, ascii]
--write Allow write actions (`driver terminate`); each also needs --confirm (in the terminal UI, the token typed). Without it ergo-aeron only reads
--action-log <PATH> Where each write's intent and result are logged (default: `ergo-aeron/actions.log` under `XDG_STATE_HOME`, else `~/.local/state`). A write that cannot be logged is refused
--archive-dir <DIR> An Aeron Archive's directory, read as files and never written: the Archive dir tab and `archive-dir` (the archive may be running or stopped)
--control <URI> An Aeron Archive's control request channel: the Recordings tab, `recordings` and `recording`, through a client on the tool's own driver with --embedded, else on the attached driver. Read requests only
--control-stream <STREAM_ID> The archive's control stream id [default: 10]
--control-response <URI> The channel the archive's responses come back on (default: `aeron:ipc` for an IPC control channel, else `aeron:udp?endpoint=localhost:0`)
-h, --help Print help (see more with '--help')
-V, --version Print version
The global flags go before or after the subcommand. ergo-aeron is the
installed binary (Install).
Formats
--format table prints aligned columns, numbers right-aligned, as Aeron’s own
tools do; it is the default on a terminal. --format json prints one JSON
object per row and line; it is the default in a pipe. Labels, channels and
error text come from the driver: in a table every control character in them
becomes ? (a tab a space), and in JSON they are escaped.
$ ergo-aeron streams --format table
stream session pub pos pub limit snd pos snd limit rcv hwm rcv pos subscribers (id@pos) slowest behind headroom % channel
1001 77 97920 98304 - - - - 7@65536 9@97920 7 32384 1.2 aeron:ipc?term-length=65536
2002 5 1048576 1179648 1046528 1179648 - - 13@1040384 13 8192 94.1 aeron:udp?endpoint=10.0.0.1:40123
$ ergo-aeron counters --stream 1001 --format table
id type value per s since mark label
50 1 98304 - - type 1: 5 77 1001 aeron:ipc?term-length=65536
51 12 97920 - - type 12: 5 77 1001 aeron:ipc?term-length=65536
52 4 65536 - - type 4: 7 77 1001 aeron:ipc
53 4 97920 - - type 4: 9 77 1001 aeron:ipc
counters takes --type ID (0: the driver’s system counters), --stream N
and --channel TEXT; the last two keep stream position counters only.
--explain adds to each counter what it means, what is normal and worrying,
what to check next, its ids and its links, as text under the table or as JSON
fields (What each counter means).
Colour and icons
The screen and the command line use one palette, from the 16 base ANSI colours (no RGB, no background fills but the selected row), so it reads on a dark or a light background:
| Style | Means | Where |
|---|---|---|
| green | healthy, running | an OK verdict, a healthy stream, a live or valid recording, [READ ONLY] |
| yellow | warning, lagging, stale | a WARN verdict, a lagging stream or recording, a loss row, [PAUSED], [LIVE RECEIVER] |
| red | error, dead, invalid | an ALARM verdict (bold), a dead stream, an error row, an INVALID entry, a watched counter that rose |
| cyan | ids and names | stream, session, counter and recording ids, field names |
| dim | secondary text | counter types, times, channels, sources, the help line |
| bold | headers | every column header |
A row is lagging when its publisher has under half of its window left (or an active recording is over 1 MiB behind its stream), and dead when its publisher is at its limit or an IPC publication has no subscriber. Each tab that shows a status has an icon column before its table: Counters, Streams, Errors, Loss, Driver, Recordings and Archive dir (Messages and Payload have none).
Four icon sets, from the best the terminal can show to plain text:
| Meaning | nerd | emoji | unicode | ascii |
|---|---|---|---|---|
| healthy | U+F00C | ✅ | ✓ | OK |
| warning | U+F071 | 🟡 | ▲ | WARN |
| error | U+F057 | ❌ | ✗ | ERR |
| lagging | U+F017 | 🐌 | ↓ | LAG |
| stopped, dead | U+F04D | ⛔ | ■ | STOP |
| paused | U+F04C | 💤 | ‖ | HOLD |
| live | U+F111 | 🔴 | ● | LIVE |
| connected | U+F1E6 | 🟢 | ◆ | CONN |
| stream | U+F0EC | 🌊 | ≈ | STRM |
| publication | U+F093 | 📤 | ▸ | PUB |
| subscription | U+F019 | 📥 | ◂ | SUB |
| recording | U+F130 | 📼 | ◉ | REC |
| archive | U+F187 | 📦 | ▤ | ARCH |
| driver | U+F013 | 🔧 | ⌂ | DRV |
| counter | U+F292 | 🔢 | # | CTR |
Each set has one fixed width (1 cell, 2 for emoji, 4 for the ASCII tags), and the icon sits in a column of its own, never inside an aligned number.
--icons nerd|emoji|unicode|ascii|auto chooses the set; so does the
environment variable ERGO_AERON_ICONS, and the flag wins over it. With
auto, which a program cannot do perfectly, it goes by:
- no UTF-8 locale (
LC_ALL,LC_CTYPE, thenLANG), orTERM=dumb:ascii; nerdwhen a Nerd Font is installed (on macOS a Nerd Font file name in~/Library/Fonts,/Library/Fontsor/System/Library/Fonts, one folder level deep; elsewherefc-listnamingNerd Font,NFMorNFP, given half a second), orNERD_FONT=1. The answer is kept 24 hours inicons-probebeside the history file (--no-historykeeps none);emojion a terminal known to draw it (TERM_PROGRAMofiTerm.app,Apple_Terminal,WezTerm,vscodeorghostty; kitty);- otherwise
unicode.
Installed is not selected: a program cannot read which font the terminal uses.
If the terminal is set to another font, the Nerd icons draw as empty boxes:
give --icons emoji (or set ERGO_AERON_ICONS) and it stays that way.
Colour on the command line follows --color auto|always|never:
autocolours when standard output is a terminal, unlessNO_COLORis set to anything non-empty.CLICOLOR_FORCE(set, not0) colours a pipe too;NO_COLORwins over it,CLICOLOR=0andTERM=dumbturn it off.alwayscolours whatever the environment says;neverprints plain text with no icons.
Colour and the icon column go on tables, health, history and the archive
commands, only on a terminal or when forced; the icons come from --icons or
the detection above. --format json, a pipe, and --color never print the
plain text the book shows, byte for byte. In the terminal UI NO_COLOR keeps
bold, dim and reversed text and drops every colour. Secondary text is dimmed
(SGR 2) in the terminal’s own foreground colour, so it reads on any theme. The
messages and log output print plain; the archive-dir segment, frame and
disk tables and recording-lag only get a bold header.
--watch SECONDS prints again every so many seconds until interrupted; from
the second read on, per s is the change per second (a single run, as above,
has no earlier read and prints -). health reads twice by itself and has no
--watch: giving it one is an error. A reader that stops
reading ends the run quietly with status 0:
ergo-aeron counters --watch 1 | head -1
ergo-aeron streams | jq 'select(.headroom_pct != null and .headroom_pct < 10)'
Copy and select
The terminal UI captures the mouse (clicks pick tabs, rows and columns), so
the terminal cannot select text while it does. M turns capture off, and the
top line says [MOUSE OFF ...]; select and copy with the terminal as usual,
then M turns it on again. --no-mouse starts with it off. The terminal is
given its mouse back when the tool exits.
y copies the open message preview, as plain text with no colour, to the
clipboard. It sends the terminal the OSC 52 sequence, which the terminal
decodes itself, so it also works over ssh and kubectl exec. The terminal
has to accept OSC 52 (some ask for it to be allowed in their settings). Inside
tmux it needs set -g set-clipboard on: tmux’s manual says its default,
external, ignores the sequence from applications.
One copy holds at most 55,000 bytes, which stays within what terminals
accept: a longer preview is cut after a whole line, and the status line says
how many lines were copied. For the whole of a large message, use
ergo-aeron messages.
health and snapshot
health reads twice, --between MS apart (default 1000), and prints one
verdict with its reasons (what it watches):
$ ergo-aeron health --format table
ALARM
Sender flow control limits, i.e. back-pressure events: rose by 3 to 3
snapshot prints everything as one JSON document (driver, health, streams,
counters, errors, losses and any part of the read that failed), for a support
bundle.
messages
messages --stream N prints a stream’s messages, read from its log file with
no subscription (why), decoded with --schema (files,
directories, or with feature http HTTPS URLs; repeatable). Without
--stream it takes the driver’s only stream, or names them all and exits 2.
It prints what the driver still keeps of the stream and exits; --follow
then keeps printing new messages until interrupted. --session S picks one
session of a stream with several. With --embedded, --channel URI --stream N --follow joins the stream through the tool’s own driver as a guarded
receiver instead (Attached or embedded); a receiver has nothing
retained, so --follow is needed and --counts is not offered. Without
--schema, a stream or channel read before has its schemas offered on
standard error: schemas used with stream N last time: ....
$ ergo-aeron messages --stream 1001 --schema car.xml --format compact
Exact Car { serialNumber: 1234, modelYear: 2013, available: T, code: A, someNumbers: [10, 20, 30, 40, 50], vehicleCode: "ABCDEF", extras: sportsPack|cruiseControl, engine: { capacity: 2000, numCylinders: 4, maxRpm: 9000, manufacturerCode: "123", fuel: "Petrol" }, fuelFigures: [{ speed: 30, mpg: 35.9 }, { speed: 60, mpg: 25.0 }], performanceFigures: [{ octaneRating: 95, acceleration: [{ mph: 30, seconds: 4.0 }, { mph: 60, seconds: 7.5 }] }], manufacturer: "Honda", model: "Civic VTi" }
Exact Car { serialNumber: 1234, modelYear: 2013, available: T, code: A, someNumbers: [10, 20, 30, 40, 50], vehicleCode: "ABCDEF", extras: sportsPack|cruiseControl, engine: { capacity: 2000, numCylinders: 4, maxRpm: 9000, manufacturerCode: "123", fuel: "Petrol" }, fuelFigures: [{ speed: 30, mpg: 35.9 }, { speed: 60, mpg: 25.0 }], performanceFigures: [{ octaneRating: 95, acceleration: [{ mph: 30, seconds: 4.0 }, { mph: 60, seconds: 7.5 }] }], manufacturer: "Honda", model: "Civic VTi" }
--format | Prints |
|---|---|
table (terminal default) | position, time read, length, match class, message and the one-line reading |
json (pipe default) | one object per message: position, seen_ms, session, stream, length, class, message, the one-line reading and the inspector’s own JSON reading |
compact | the one-line reading |
pretty | where the message sits, then one field per line |
raw | each message as a 4-byte little-endian length and its bytes; refused on a terminal |
raw is a framing sbe-inspect detects, so a capture can be decoded later
or elsewhere:
ergo-aeron messages --stream 1001 --follow --format raw > capture.bin
sbe-inspect schemas/ < capture.bin
--counts prints the count, rate and average size per message type instead
of the messages (not with --follow). A reader that falls behind the
stream (a slow pipe) skips forward to data the driver still has and says so
on standard error, fell behind: skipped N bytes ..., at most once a second;
a stalled pipe never holds the publisher. Bytes the embedded receiver never got
are said the same way, lost: skipped N bytes .... What was not yet said when
the run ends is said then, also when Ctrl-C, SIGTERM or SIGHUP ends it. The run
has 5 seconds from such a signal to end: one still running then, whether stuck
(writing to a pipe or terminal nobody reads) or still writing to a slow reader,
is ended with status 130 and says nothing more. compact, pretty and raw
are for messages only.
--interpret shows what each value means beside its raw value, and
--converters FILE (or the environment variable ERGO_AERON_CONVERTERS)
gives the rules that say so in a TOML file (what the values
mean), messages nested in var data
included. Without --interpret, and with no converters file named, the
output is what it was. The terminal UI shows the meanings without the flag;
i hides them.
log
log --stream N prints a stream’s log file as it lies, --file PATH a log
file with no driver (what it shows). Without
either it takes the driver’s only stream, or exits 2 naming them. --format table prints the metadata, then one frames table; --format json prints
{"metadata": {...}} on the first line, then one {"frame": {...}} per
frame header, each with its index (term partition), offset, the header
fields, payload and note (why the term’s walk stopped there, else
null). Each frame prints as it is read, so memory stays flat on a log of
any size. --dump BYTES (default 65536), --ascii and --scan-over-zeroes
are LogInspector’s options; --dump-all shows every payload in full.
--file refuses anything but a regular file.
ergo-aeron log --stream 1001 --scan-over-zeroes | jq -c 'select(.frame.type == 1) | .frame.offset'
driver terminate
The one write action: refused unless given --write and --confirm PID@START_MS with the driver’s pid and start time
(how it works).
ergo-aeron driver terminate --dry-run # the preview and the token; sends nothing
token=$(ergo-aeron driver --format json | jq -r '"\(.driver.pid)@\(.driver.start_ms)"')
ergo-aeron driver terminate --write --confirm "$token" --wait 5000
It prints termination requested ... on standard output, then ... has stopped once the driver is gone; what it prints never changes the exit
status, so a reader that closes the pipe early cannot make it exit 0. The
path of the action log is named on standard
error. In the terminal UI the same action is behind --write and the typed
token (In the terminal UI).
The archive commands
recordings and recording ID read an Aeron Archive over its control
session (--control URI), recording-lag the archive’s driver’s counters,
and archive-dir ... an archive directory’s files (--archive-dir DIR),
ArchiveTool’s read commands among them (Archive tabs). Each
prints --format table or json once (no --watch). replay ID (also
--control) prints a recording’s messages in the formats of messages, and
with --follow goes on while it records
(payload).
ergo-aeron --archive-dir /data/archive archive-dir describe --format json | jq -r 'select(.stream_id == 1001) | .recording_id'
ergo-aeron --archive-dir /data/archive archive-dir verify || echo "Java's verify would mark an entry INVALID"
history
history lists the aeron directories, streams, channels, schema sources,
archive directories and archive control channels used before, newest first,
as a table or JSON lines; history clear forgets them; --no-history (any
command) reads and writes none (history).
Exit status
| Status | When |
|---|---|
| 0 | printed; or the reader closed the pipe (not for driver terminate); or a followed stream closed; for driver terminate, only that the driver stopped: its cnc.dat gone, its heartbeat cleared or another driver started there; or its --dry-run printed |
| 1 | health judged ALARM; or driver terminate was sent and, after --wait, the driver still runs, does not answer (heartbeat stale, files still there: it may be paused) or cannot be read; or an interrupt (--embedded only) ended the --wait: it prints that the termination was requested and is not confirmed; or archive-dir verify found an entry Java’s verify would mark INVALID |
| 2 | for archive-dir, no --archive-dir, or a catalogue, mark file or segment that cannot be read or holds a length Aeron never writes (what was printed before it stands); for recordings, recording and replay, no --control, a control channel that is not an aeron: URI, no archive answering in 10 s, no such recording, an aeron:ipc control channel with --embedded, or a build without the archive control reader; for replay, also a position outside the recording or inside a frame, --format raw to a terminal, a schema that does not load, or a replay that the archive fails, never connects or ends short of what was asked (what was printed before it stands) |
| 2 | in embedded mode, the driver did not start, its directory exists, or the channel is refused (fc=min, IPC, a spy, a parameter given twice), or AERON_CONGESTIONCONTROL_SUPPLIER names a supplier other than default or static; a --channel without --embedded; history with history off; an interrupt (--embedded only) between the two reads of health --between, which prints no verdict; no driver could be read at the directory (health then prints no verdict, only the reason), or bad arguments (including health --watch), or no subcommand with stdout not a terminal (the screen is never written into a pipe); for messages and log, also a stream that is not there or cannot be chosen; for messages, a schema that does not load, or --format raw to a terminal; for log, a log file that is not a regular file, cannot be read or fails its checks; for driver terminate, a refusal (no --write, no --confirm, a token that does not match, a driver that is no longer the one read or whose heartbeat is already stale, or an action log that cannot be written, or an interrupt before the request was sent, or --embedded with no other driver’s directory in --aeron-dir: nothing was sent) or a request that could not be written |
| 130 | with --embedded, messages --follow or replay --follow, the run was still going 5 seconds after SIGINT, SIGTERM or SIGHUP and was ended; an embedded driver’s directory may be left behind |
Diagnostics go to standard error, one line each, starting ergo-aeron:; a
control character in them (a directory name, Aeron’s text) shows as ?.
health --format json spells the verdict as the table does (OK, WARN,
ALARM).