Cluster SSH (OSX)
code.google.com
code.google.com
http://taktuk.gforge.inria.fr/kanif/
This is a great tool to do mass changes to our 1200 CPU compute cluster. The best part about this is, it will map all of the hosts with the same output together and reduce this down to just one instance of the output, with the affected hostnames listed together. So instead of 500 instances of the same output data I get one. This comes in handy for finding hosts which are different than what I'm looking for.
Simple example:
--------------------------------------------------------------------------------
compute[0009,0051,0187] (3 HOSTS)
--------------------------------------------------------------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
58G 14G 42G 25% /
--------------------------------------------------------------------------------
compute[0013,0038,0044,0046,0065,0103,0125,0142,0195,0213,0216,0234] (12 HOSTS)
--------------------------------------------------------------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
58G 11G 44G 19% /
--------------------------------------------------------------------------------
compute0247 (1 HOST)
--------------------------------------------------------------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
58G 7.6G 47G 15% /It was also fun to terrify first year students with 20 cd trays ejecting at the same time...
for h in host1 host2 host3; do \
echo -e "\n$h\n===========\n"; \
ssh $h 'ln -s /some/path /path/to/link && ls -l /path/to/link'; \
done
edit: woops, left out a couple semicolons...Exactly.
One-offs are easy to test interactively with cssh, and despite what anyone thinks, there are always one-offs in the real world.
In short, use automation with care.
Thank you for this comment, I never knew you could pass commands to ssh.
Example:
dsh -Mg all-machines -F 20 'do something'
-M: Prepend any line of output with the machine that emitted it
-g: runs the group all-machines (just a text file in etc/dsh/group)
-F 20: forks at most 20 copies of ssh in the background so you don't overload the server you're running this from
for i in `seq 1 30`; do \
echo -e "\nhost$i\n===========\n"; \
ssh host$i 'ln -s /some/path /path/to/link && ls -l /path/to/link'; \
done
Also, if you just start typing for i in `seq 1 30`
do
commands
more commands
done
On the command line itself, you don't need to worry about semicolons. Bash will take care of it. for i in {1..30}; do...Good point about not needing semicolons for multiple-line stuff (assuming the EOL's are not escaped, as you have it in your example). I blame the PHP I spent all week immersed in...bleh.
I've certainly done my share of ssh in a for loop, but if you're seriously considering this you almost certainly want to look into puppet/chef/cfengine/etc.
C-b % [n times, n panes]
C-b M-5 [tiled layout]
### ssh into your servers in each pane, or whatever
C-b : setw sy <tab> [short for "synchronize-panes"]
### have synced fun!I've been using sshpt and pssh for this sort of thing:
Does anything like that exist? I guess the downside would be fixing problems if your command failed in 1 or 2 of 10 or 20 servers… Then you'd have to open up a separate session to those servers to figure out what was going on.
also for clusters i wrote a python script using libcloud that connects multiple terminals and does some bastardized map/reduce type helper ideas:
#!/bin/bash
if [[ "$1" = "-n" ]]; then
DETACH=
shift;
else
DETACH="screen -d -m"
fi
for i in $NODES; do
echo $DETACH ssh $i $@
$DETACH ssh $i $@
done;Came in useful from time-to-time.
It's under 15 identical machines, so it is more trouble than it is worth to set up Puppet or something of that sort.
I use fabric http://fabfile.org/ which is insanely easy to use.
I use it even if I have one machine to deploy to. Better keep them deployments repeatable ...
fab -H system1,system2,system3 -- uname -a