1 |
#!/usr/bin/perl |
2 |
|
3 |
# usage: test-all.pl hosts |
4 |
|
5 |
use warnings; |
6 |
use strict; |
7 |
use autodie; |
8 |
use File::Slurp; |
9 |
use Data::Dump qw(dump); |
10 |
|
11 |
chdir '/srv/sysadmin-cookbook/recepies/netpipe-tcp/'; |
12 |
|
13 |
my @hosts = read_file 'hosts'; |
14 |
@hosts = map { chomp; $_ } @hosts; |
15 |
warn "hosts = ",dump(@hosts); |
16 |
|
17 |
foreach my $host ( @hosts ) { |
18 |
chomp($host); |
19 |
|
20 |
my @test; |
21 |
|
22 |
foreach my $to ( @hosts ) { |
23 |
next if -s "$host/$to.np"; |
24 |
warn "start NPtcp on $to\n"; |
25 |
system "ssh $to NPtcp &"; |
26 |
push @test, $to; |
27 |
} |
28 |
|
29 |
warn "# missing ", dump(@test); |
30 |
|
31 |
open(my $ssh, '|-', "ssh $host xargs -i NPtcp -h {} -u 1048576 -o /tmp/{}.np"); |
32 |
foreach my $to ( @test ) { |
33 |
warn "TEST from $host to $to\n"; |
34 |
print $ssh "$to\n"; |
35 |
} |
36 |
close($ssh); |
37 |
|
38 |
system "rsync -v $host:/tmp/*.np $host/"; |
39 |
} |