in reply to using Net::Telnet to test Apache
I've seen the advice n times (where n > 3) to use the LWP libs instead of Net::Telnet. The problem is, http://mydomain.com does not specify which http daemon actually serves the page. It looks like IO::Socket::INET is the next best bet, this module lets one specify hostnames. Anyway, here's a working version of the originally posted code:
#!/usr/bin/perl use strict; use Time::HiRes qw( time tv_interval ); use Net::Telnet (); $0 = 'ruffbench'; unless (@ARGV){ die "Usage: $0 <host> [<host2> <host3> ...]\n"; } my $port = '80'; my $t = new Net::Telnet; my $get = "GET / HTTP/1.0\n\n"; my %time; foreach my $host (@ARGV) { print "$0: Connecting to $host. Starting timer.\n"; my $start = [ time() ]; $t->open(Host=>$host, Port=>$port); print "$0: Connected to $host. Sending request...\n"; $t->print($get); print $t->waitfor(String=>"Content-Type", Timeout=>5 ); my $end = [ time() ]; $t->close; print "\n$0: Connection closed. Timer stopped.\n\n"; $time{$host} = tv_interval($start, $end); } print "$0: Summary of results:\n"; foreach my $host (@ARGV) { printf "%9s: %10s ... %2.2f seconds\n", $0, $host, $time{$host}; }
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: using Net::Telnet to test Apache
by Fastolfe (Vicar) on Nov 14, 2000 at 03:52 UTC | |
by meonkeys (Chaplain) on Nov 14, 2000 at 07:05 UTC | |
by Fastolfe (Vicar) on Nov 14, 2000 at 07:37 UTC | |
by meonkeys (Chaplain) on Nov 14, 2000 at 07:55 UTC | |
by merlyn (Sage) on Nov 14, 2000 at 08:11 UTC | |
by AgentM (Curate) on Nov 14, 2000 at 07:24 UTC | |
by meonkeys (Chaplain) on Nov 14, 2000 at 07:51 UTC | |
by AgentM (Curate) on Nov 14, 2000 at 08:23 UTC |
In Section
Seekers of Perl Wisdom