The Rig
The Rig runs commands from preset files in parallel, presenting the aggregated output in different ways.
Usage
Create a “preset.yaml” file.
Say, for example, that you want to have a look at how much space is being wasted by logs on some remote hosts you manage.
label: "du {{.host}}:{{.path}}"
command: ["ssh", "{{.host}}", "du", "-sh", "{{.path}}" ]
arguments:
- { host: "example.com", path: /var/log }
- { host: "example.org", path: /var/log }If a preset file defines one or more argument dictionaries, the command line and the label will be treated as a templates, and one instance of the command is run for each argument dictionary, after placeholders have been replaced with the actual named arguments values.
Order of execution
- commands from different preset files given as positional arguments to the Rig are run in parallel.
- commands generated by interpolating arguments from a single preset are run
serially (eg.: one starts only after the previous has finished but
irregardless of failure or success).
- they can be forced to run in parallel using the
--fearlessoption.
- they can be forced to run in parallel using the
Run the Rig
rig report log-size.yamlThe output will look like this, except for colors
du example.com:/var/log/* | PID 83508: ssh example.com du -sh /var/log/* du example.com:/var/log/* | du: /var/log/secret: Permission denied du example.com:/var/log/* | 16K /var/log/auth.log du example.com:/var/log/* | 12K /var/log/cron du example.com:/var/log/* | 152K /var/log/messages du example.com:/var/log/* | finished after 0.75s with error: exit status 1 du example.org:/var/log/* | PID 83508: ssh example.org du -sh /var/log/* du example.org:/var/log/* | du: /var/log/secret: Permission denied du example.org:/var/log/* | 22K /var/log/auth.log du example.org:/var/log/* | 3K /var/log/cron du example.org:/var/log/* | 200K /var/log/messages du example.org:/var/log/* | finished after 1.48s with error: exit status 1 all commands failed
The report subcommand will buffer the commands output and print it only
when the command finishes. Who finishes first gets it’s output printed
first.
The stream subcommand instead print each commands output as it comes in,
without any buffering or ordering, and is more suitable for running commands
like tail.