use Time::HiRes qw(gettimeofday tv_interval); open(OUTPUT,">results.txt"); my @strHosts = (); my $iHosts = 0; $strHosts[$iHosts++] = 'server1totest.domain.com'; $strHosts[$iHosts++] = 'server2totest.domain.com'; #$strHosts[$iHosts++] = 'serverXtotest.domain.com'; $strHosts[$iHosts++] = 'server3totest.domain.com'; $strHosts[$iHosts++] = 'server4totest.domain.com'; $strHosts[$iHosts++] = 'server5totest.domain.com'; $strHosts[$iHosts++] = 'server6totest.domain.com'; $strHosts[$iHosts++] = 'server7totest.domain.com'; $strHosts[$iHosts++] = 'server8totest.domain.com'; $strHosts[$iHosts++] = 'server9totest.domain.com'; $strHosts[$iHosts++] = 'server10totest.domain.com'; $strHosts[$iHosts++] = 'server11totest.domain.com'; print OUTPUT "Host\tTime\tResult\n"; for(my $i = 0; $i < 1000000; $i++){ my $iRandomNumber = int(rand() * 100); $iRandomNumber = $iRandomNumber % $iHosts; my $strHost = $strHosts[$iRandomNumber]; my $t0 = [gettimeofday]; my $strResult = &runTest($strHost); my $fElapsedTimeAuthentication = tv_interval ($t0, [gettimeofday]); my $strStatus = "FAILURE"; if($strResult =~ /^$strHost$/i){ $strStatus = "SUCCESS"; } printf "$i\t$strHost\t%.8f\t$strStatus\n", $fElapsedTimeAuthentication; printf OUTPUT "$i\t$strHost\t%.8f\t$strStatus\n", $fElapsedTimeAuthentication; if($i % 100 == 0){ sleep(2); } } close OUTPUT; exit(0); sub runTests{ my $strHostname = $_[0]; open(SSH,"/usr/bin/ssh targetUID\@$strHostname hostname |"); while(){ chomp(); if( length($_) > 5){ $strResult = $_; } } close SSH; }