Running a Command on Multiple servers using Free Fanout Utility

Fanout is a nifty tool for sysadmins to quickly run a set of commands on multiple servers:

It runs non-interactive commands (like ddcatadduseruname -a, etc.) and pipelines built of these. The output is collected into a single display that can be viewed by less or redirected to a file

You can group servers under a variable & run commands like below:

PROD_SERVERS=S1 S2 S3 S4
./fanout "$PROD_SERVERS" "uname -a"

this will run command on all servers S1-S4 and show consolidated output on screen

You can as many combinations of complex commands as you want:

example:

fanout “$SERVERS” “uname -a ; ( if [ -f /var/log/dmesg ]; then cat /var/log/dmesg ; else dmesg ; fi ) | egrep -i ‘(hd[a-h]|sd[a-h])’ ; ls -al /proc/kcore ; cat /proc/cpuinfo” >serverspecs

Pre-Requisites for smoother operation

  • Setup ssh-keys between hosts so that u do not need to key in your password each time, there will be no point of using this tool if you do not have ssh-keys setup between hosts
  • You need to run this from the main jump server where u created your private key, also public key of corresponding private key should be added under ~/.ssh/authorized_keys file on all other hosts.

Above steps are  1 time efforts only, once done you can run as many commands you want to get desired results from multiple servers in single command.

Source: http://www.stearns.org/fanout/filelist.html

Direct Download Link: http://www.stearns.org/fanout/fanout

PS: It is just a shell script not a binary.

 

Leave a Reply