pssh: Execute a command on multiple hosts on terminal
April 15, 2010 Leave a comment
If you deal with the task of manage multiple machines in a local network, it is usual need to apply a given settings over all hosts, or install a new program on the entire network. We’ve posted before a tool called cluster-ssh which hold it via interface (or exporting X). However, if you could not export X you can use pssh, a tool that dispatch a command to multiple hosts in terminal. It can be found on Ubuntu repositories, but in Karmic Koala it does not work. The installation completes, but it does not create the binary in /bin, /usr/bin neither in /usr/local/bin). The turnaround is presented below:
sudo add-apt-repository ppa:thelupine/ppa sudo apt-get update sudo apt-get install pssh
After installing it, you can check, for instance, who is accessing each machine, what’s the load on each machine, what are the mounted devices and so. First you need to create a file with a list of all hosts:
### hosts.txt ### server1 server2 server3 server4
Then you can dispatch the command to be distributed:
pssh -h hosts.txt -i "df -h"