rcmd (remote command) is a command line utility written in Ruby for executing the same command on multiple systems through ssh. This is done by assigning a host to a thread and creating the ssh sessions in those threads.
Command line switch for setting number of threads to be used at a time. (Default is 4)
A comma seperated list of hosts piped from another command can be used as the node list.
Username can be specified. (Default is root. Requires valid ssh-key in ~/.ssh)
Output shows which host the output is from
Stdout can be suppressed, only allowing for stderr to be shown
rcmd is available as a gem and kan be installed with gem install
rcmd
daibhidh@darkstar:~/$ rcmd --help Usage: rcmd [options] -u, --username username Username for SSH connections -n, --nodes x,y,z Comma seperated list of nodes. use '-' for a space seperated list piped from another command -t, --threads threads Number of threads to run -c, --command <command> Quoted string containing the command to be run -q, --quiet Suppress stdout of commands. stderr will still be displayed -v, --version Print what version of the command is in use
Specifying a comma seperated list of hosts and timing the total execution time. ```bash daibhidh@darkstar:~/$ time rcmd -n node1,node2,node3,node4 -c 'cat /etc/redhat-release' node2 :: Red Hat Enterprise Linux ComputeNode release 6.8 (Santiago) node1 :: Red Hat Enterprise Linux ComputeNode release 6.8 (Santiago) node4 :: Red Hat Enterprise Linux ComputeNode release 6.9 (Santiago) node3 :: Red Hat Enterprise Linux ComputeNode release 6.9 (Santiago)
real 0m2.749s user 0m0.272s sys 0m0.050s ```
Using the hammer cli to get a list of hosts from a RedHat Satellite and providing it to rcmd as the node list. <code>bash daibhidh@darkstar:~/$ hammer --output base host list --organization org | awk '/Name:/ {print $2}' | rcmd -n - -c 'cat /etc/redhat-release' node1.example.com :: Red Hat Enterprise Linux ComputeNode release 6.8 (Santiago) node3.example.com :: Red Hat Enterprise Linux ComputeNode release 6.9 (Santiago) node2.example.com :: Red Hat Enterprise Linux ComputeNode release 6.8 (Santiago) node4.example.com :: Red Hat Enterprise Linux ComputeNode release 6.9 (Santiago) </code>
TODO
If you are wanting to modify the code by all means do so. If you clone this
repository you can then run bundle install
to install the
dependencies needed. Tests are performed with rspec and can be run
with rake.
Available Rake tasks are:
rake build # Build rcmd-1.5.5.gem into the pkg directory rake clean # Remove any temporary products rake clobber # Remove any generated files rake clobber_rdoc # Remove RDoc HTML files rake console # Open an IRB console with this gem loaded rake install # Build and install rcmd-1.5.5.gem into system gems rake install:local # Build and install rcmd-1.5.5.gem into system gems without network access rake rdoc # Build RDoc HTML files rake reinstall # Remove, build, and install gem rake release[remote] # Create tag v1.5.5 and build and push rcmd-1.5.5.gem to Rubygems rake rerdoc # Rebuild RDoc HTML files rake spec # Run RSpec code examples