Three scripts that are not products

A pcap fan-out, a one-line ssh loop and a YAML aligner — 180 lines between them, each with a limit worth stating.

Automation

fetch-pcap-multi.sh, 65 lines

There is an existing fetch-pcap tool (not mine) that pulls one capture from one source. The wrapper exists because troubleshooting a signalling path means capturing at several points at the same moment, and starting four terminals by hand loses the "same moment" part.

The spec format is positional and does double duty:

-s host:file.pcap              # whole host
-s host:container:file.pcap    # one container on that host
-s alias:file.pcap             # a preconfigured alias

Parsing is one IFS=':' read -r part1 part2 part3, and a two-field spec is told from a three-field one by whether part3 came back empty. It forks one fetch-pcap per source, keeps the PIDs in an array, then waits on them in order (job 1 first, regardless of which finishes first) and prints a tick or a cross per job. Output filenames get : and / squashed to _ before use (${out_file//[:\/]/_}), because the host part of the spec ends up in the name (: in a container spec, / in a path).

The omissions are the point: no concurrency cap, no retry, no timeout. Pass it twelve sources and you get twelve simultaneous captures (twelve taps, twelve open files, one operator). set -e is on, but the wait "$pid" && echo ok || echo failed form swallows the failure, so a dead job reports and the script carries on — which is the behaviour you want from a fan-out and happens here by accident, not design.

get_container.sh, 51 hostnames

This one is barely a script. A single cmmd variable at the top holds a shell command; a for loop ssh's it to 51 production hosts in sequence and prints the hostname before each result. No parallelism, no error handling, no arguments (the hosts are a literal array in the file).

The interesting part is the comment block above cmmd — five previous commands kept in place (one per investigation):

# cmmd='sudo docker ps --format "table {{ .Names }}\t\t{{ .Status }}"'
# cmmd="awk '/VmRSS/ {printf \"RSS: %.3f GB\n\", \$2 / 1024 / 1024}' \
#       /proc/\$(pidof fluent-bit)/status"
cmmd='sudo docker ps | grep frr'

That is the real interface. You comment out the current line, write a new one, and run it again — and the history of what you have asked the fleet stays in the file (memory of a log-forwarder, a grep for one error string on one date, a check for which hosts run a routing daemon). The last committed change to this file was to the awk expression, not to the host list, which tells you which part actually gets edited.

Fifty-one hostnames hard-coded in an array (four sites, dev and prod mixed) is the obvious flaw and also the reason it has never broken. There is no inventory parsing to go stale.

align-colon.py, 67 lines

Two modes, chosen by a second positional argument. global pads every key in the file to the length of the longest key; per-block pads keys only against others at the same indentation depth (one maximum per indent width). It rewrites in place, with no backup.

The limit is in the regex. Every line with a colon is matched as ^(\s*)([^:#\n]+?):\s*(.*) and reassembled as padded key, colon, space, stripped value — so a value that itself contains a colon is split at the wrong one. Run it over a scrape config and - http://host:9090 becomes - http: //host:9090 — valid YAML, wrong YAML (a key where a list item was). Lines whose first colon follows a # are skipped, so comments survive, and that is the only guard there is.

So it is a tool for flat key-value files, and I use it on exactly those. Knowing that in advance costs nothing; finding it out by committing a mangled config costs a revert.

What they have in common

None of the three takes a config file, none has a test, and none would survive being handed to someone else without a conversation. Each took under a day and paid for itself the first time it ran (180 lines, three problems, no dependencies beyond ssh and Python). The honest category for all three is "personal tooling" — scripts shaped around one operator's habits, with the failure modes left in because the operator knows where they are.

The cost of that choice shows up exactly once: when somebody else needs the tool and the shape of it is in your head.