[Chugalug] PHP help?

Joe Freeman joe at netbyjoe.com
Wed Nov 28 16:58:10 UTC 2012


I posted this on StackOverflow, but thought I'd check with folks here to
see if they have any suggestions-


I am converting some perl code using LWP::UserAgent::DNS::Hosts to php.

What the perl code is doing is making page load time measurements against
multiple individual servers in a load balancing pool. Since the servers are
using name based virtual hosting, the perl code uses this line to change
the url/hostname to ip binding:

    LWP::UserAgent::DNS::Hosts->register_host(
    'www.mytesturl.com' => '22.22.22.22',
    );

    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;

    #actually enforces new DNS settings as if they were in /etc/hosts
    LWP::UserAgent::DNS::Hosts->enable_override;

    $Timerstart=[gettimeofday];

    my $response= $ua->get('http://www.mytesturl.com');

    $TimeElapsed = tv_interval ($Timerstart,[gettimeofday]);

    if ($response->is_success) {
       print "<br>Response detected - Time to Load: $TimeElapsed seconds\r\n"
    }

I know I can do this with raw socket manipulation, but I was hoping I could
do it with cURL or another class library in PHP. The perl code actually
repeats this inside a loop with several different IP's for the same url
(each ip is a specific server) to test the servers individually.

Thanks-

Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20121128/a3c16809/attachment-0001.html>


More information about the Chugalug mailing list