Scripting and CI
witr is built to be scripted, not only read. Two things make that work: --json and real exit codes.
JSON output#
witr --port 8000 --jsonWorks with every target type and with multiple mixed targets in one call. Combine with jq to pull out exactly the field a check needs.
Branching on the exit code#
witr nginx --short
case $? in
0) echo "All clear" ;;
1) echo "Warnings detected" ;;
2) echo "Process not running" ;;
3) echo "Need elevated privileges" ;;
4) echo "Invalid input or ambiguous match" ;;
5) echo "Internal error" ;;
esacThe distinction between 2 (not running) and 3 (cannot tell, no permission) matters in a monitoring context, where treating a permission failure as an outage produces false alarms. See Exit Codes for the full table.
A deploy pre-flight check#
if witr --port 8000 --short > /dev/null 2>&1; then
echo "Port 8000 is occupied. Chain:"
witr --port 8000 --short
exit 1
fiThe chain in the failure message means whoever reads the CI log gets the cause, not just the symptom.
Watching for warnings#
witr --pid "$APP_PID" --warnings --jsonExit code 1 means at least one warning fired — a public bind, a restart loop, a deleted binary after an upgrade that never restarted the service.
Output modes that combine#
Every mode works with multiple inputs and with each other where it makes sense:
| Flag | Effect |
|---|---|
--short |
Ancestry chain only, one line |
--tree |
Ancestry as a tree, with children |
--json |
Machine-readable, real exit codes |
--env |
Environment variables for the process |
--warnings |
Warnings only |
--verbose |
Extended process information |
--no-color |
Disable colour, useful in logs |
Full list in the flags reference.