On Mon, 22 Mar 2004 [EMAIL PROTECTED] wrote:
..
> Would anybody happen to know a tool that can generate multiple HTTP
> connections simultaneously? I need it in stress testing a certain proxy
> server. I need to know its capacity.
I wrote a simple script that uses LWP::UserAgent to do this.. you can hack
it appropriately as you wish. :)
here it is..
#!/opt/perl5/bin/perl
use LWP::UserAgent;
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval );
use POSIX;
my $idx = 1;
$url = $ARGV[0];
# first: fork 10 children
my $ccount = 0;
while ($ccount < 10) {
my $fr = fork;
if ($fr == 0) {
$ccount = 10;
} else {
$ccount++;
}
}
my $pid = POSIX::getpid();
open (O, ">out.$pid") or die;
select (O);
while ($idx <= 25) {
my $t0 = Time::HiRes::time();
my $agent = new LWP::UserAgent;
my $req = new HTTP::Request GET => $url;
my $res = $agent->request($req);
if (! $res->is_success) {
print "[$idx] get failed\n";
print STDERR "[$idx] get failed\n";
} else {
my $t1 = Time::HiRes::time();
my $sz = length ($res->content);
my $dur = $t1 - $t0;
my $bw = $sz / $dur;
my $sec = sprintf ("%1.3f", $dur);
print "[$idx] duration = [$sec], sz = [$sz], bw = [$bw]\n";
print STDERR "[$idx] duration = [$sec], sz = [$sz], bw = [$bw]\n";
}
$idx++;
}
select (STDOUT);
close (O);
exit;
--
Philippine Linux Users' Group (PLUG) Mailing List
[EMAIL PROTECTED] (#PLUG @ irc.free.net.ph)
Official Website: http://plug.linux.org.ph
Searchable Archives: http://marc.free.net.ph
.
To leave, go to http://lists.q-linux.com/mailman/listinfo/plug
.
Are you a Linux newbie? To join the newbie list, go to
http://lists.q-linux.com/mailman/listinfo/ph-linux-newbie