Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've server Master,SlaveA,SlaveB,SlaveC, and want to get eg. the space information from the server by executing one bash script on the master.

How can I do that?

--case--
192.168.1.1 - Master
192.168.1.10 - A
192.168.1.11 - B
192.168.1.12 - C

Get df on slaves.

--ex. output---
==Slave A==
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             7222500   3909896   2945720  58% /
==Slave B==
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             4222500   3909896   5744447  98% /
==Slave C==
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             1222500   509896   xxxxxxxx  50% /

Many Thanks! DeLol

share|improve this question
1  
You should consider using tools like Nagios and Munin for this sort of thing rather than running scripts manually. –  ThatGraemeGuy Apr 10 '13 at 13:39
    
@ThatGraemeGuy: Nagios etc. is fine, but it doesn't tell you more than that everything is OK. Sometimes I just want to have a list of data from several servers, or do something on all of them. And no, Puppet etc. isn't always the answer. –  SvW Apr 10 '13 at 13:42
    
I'm not sure what Puppet has to do with this, since that's used for configuration management. Nobody even mentioned it. –  ThatGraemeGuy Apr 10 '13 at 13:48
    
@ThatGraemeGuy: It was just a proactive statement from my side, not necessarily aimed to you directly, but tools like puppet are usually the next thing mentioned in discussions like that. "You want to do things on many machines. Use puppet/chef/cfengine". –  SvW Apr 10 '13 at 14:06
    
dsh can handle this for any arbitrary command. –  Mike Renfro Apr 11 '13 at 2:45
add comment

2 Answers

For a limited list of clients I have a bash function in my ~/.profile:

ch () {

   echo host1
   ssh root@host1 $@
   echo host2
   ssh root@host2 $@
}

I call this like this:

ch df

This can be easily expanded to a list of clients read from an array or a config file.

Another option is to use something like cssh or similar.

share|improve this answer
add comment

Put the commands you need in a quick script on the master and run the script like this:

ssh 192.168.1.10 < script.sh

This executes the commands contained within script.sh on the remote host without copying script to the remote system.

Also see: Documenting server details

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.