parallel ssh (pssh) with output stream

1.6k Views Asked by At

I have 3 servers and I want to run a command on all of them parallely from a client and see the output as it streams.

I have tried using pssh but it shows output only when the command exits. But what I want is the output from all the servers on the stdout of my client as it produces output before exiting.

For example, when I run "ping google.com" on all the servers, I get output only when I hit Ctrl+C like this:

Output when I hit Ctrl+C

My command looks like this:

pssh -h server_list -l userName -i pemFile.pem 'ping google.com'

How to see the ping output from all the 3 servers as it pings?

1

There are 1 best solutions below

1
On

I was trying to achieve the same, and the best way for me was to specify an output directory and then follow the stream on the output files, like so:

We add -o /tmp/out -t 0 so we get the output of each host to the specified directory, and we do not get any timeout.

pssh -h server_list -l userName -i pemFile.pem -o /tmp/out -t 0 'ping google.com'

Leave that running, and then follow the streams. Assuming you have host1, host2, host3, and host4 in your server_list, you can do the following: tail -f /tmp/out/host{1,2,3,4}