Skip to content

Instantly share code, notes, and snippets.

@mcmillhj
Created December 18, 2014 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmillhj/134060c5ecacd78953e1 to your computer and use it in GitHub Desktop.
Save mcmillhj/134060c5ecacd78953e1 to your computer and use it in GitHub Desktop.
ssh into a list of servers and call the top command, then concatenate the results into a single file
#!/usr/bin/perl
use strict;
use warnings;
exit(0) unless @ARGV;
open(my $fh, '>>', 'mutlti-top.out') or die "$!";
foreach my $server ( @ARGV ) {
print {$fh} `ssh ${server} top -bn 1`;
}
close($fh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment