#!/usr/bin/perl

# usage: test-all.pl hosts

use warnings;
use strict;
use autodie;
use File::Slurp;

chdir '/srv/sysadmin-cookbook/recepies/netpipe-tcp/';

my @hosts = read_file 'hosts';

foreach my $host ( @hosts ) {
	chomp($host);

	foreach my $to ( @hosts ) {
		chomp($to);
		warn "start NPtcp on $to\n";
		system "ssh $to NPtcp &";
	}

	warn "TEST from $host\n";
	system "cat hosts | ssh $host xargs -i NPtcp -h {} -u 1048576 -o /tmp/{}.np";
	system "rsync $host:/tmp/*.np $host/";
}
