Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

There is a way using perl to find out in a given URL how long the site is taken to load into the browser window and if it is taking too long to send a warning or an e-mail about the possible loading time problem?

Replies are listed 'Best First'.
Re: Loading time
by blue_cowdawg (Monsignor) on Sep 04, 2003 at 22:47 UTC

    LWP and Benchmark are your friends.

    Just to give you and idea in psuedocode:

    mark starting time use LWP to get the page mark finish time calculate difference send email if difference is too much

    Try it, you'll like it. Or you could use Nagios... but this is a Perl Monks site not a Nagios site... ;-)


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
Re: Loading time
by Abigail-II (Bishop) on Sep 04, 2003 at 22:55 UTC
    Uhm, yeah, you could use Perl. But determining whether something takes "too long" isn't simple. There's a lot that is involved when requesting a URL. Your machine. Your network. The network between you and the server. The network at the server side. The load on the server. Etc, etc. Not all of them are under the control of the server. side.

    The hardest problem is figuring out what is "too long" and whose fault it is.

    Abigail

      Although I agree that it may not be a complete solution, LWP can often be used as a quick sanity check on a site.

      For a more robust version, I guess you could add calls to Net::Ping to get some idea of network latency and such.

      I actually used this as a test on some production servers. The important part was not the actual time value, but the difference from a baseline. In our case, a factor of two was not important, but a factor of ten was critical.

      G. Wade

        Don't over-estimate the value of pings though. There are too many routers out there that give priority to ICMP messages, which will make ping show much quicker round trip times that you'll get once you use TCP/IP. I'd only wish that connecting to the Internet from work was as fast as 'ping' shows. :-(

        Abigail