This source code is from- http://www.cyberciti.biz/tips/execute-commands-on-multiple-linux-or-unix-servers.html
You will need to setup SSH Share keys for this script – http://www.cyberciti.biz/tips/ssh-public-key-based-authentication-how-to.html
Bash for Loop Examples : http://www.cyberciti.biz/faq/bash-for-loop/
[sourcecode language=”bash”]
#!/bin/bash
# Linux/UNIX box with ssh key based login
SERVERS="192.168.1.1 192.168.1.2 192.168.1.3"
# SSH User name
USR="jadmin"
SUBJECT="Server user login report"
EMAIL="admin@somewhere.com"
EMAILMESSAGE="/tmp/emailmessage.txt"
# create new file
>$EMAILMESSAGE
# connect each host and pull up user listing
for host in $SERVERS
do
echo "——————————–" >>$EMAILMESSAGE
echo "* HOST: $host " >>$EMAILMESSAGE
echo "——————————–" >>$EMAILMESSAGE
ssh $USR@$host w >> $EMAILMESSAGE
done
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
[/sourcecode]
Other options
- Clusterit – http://www.garbled.net/clusterit.html
- PSSH – http://www.theether.org/pssh/
- Cluster SSH – http://sourceforge.net/projects/clusterssh/
- Tentakel – http://tentakel.biskalar.de/
- Putty Connection Manager – http://puttycm.free.fr/cms/
Reference Article - http://www.cyberciti.biz/tips/execute-commands-on-multiple-linux-or-unix-servers-part-ii.html