Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How to check if a website is up?

by nmcfarl (Pilgrim)
on Apr 05, 2004 at 04:14 UTC ( [id://342567]=note: print w/replies, xml ) Need Help??


in reply to How to check if a website is up?

This simplest solution is LWP::Simple
use LWP::Simple; my $url="http://cpan.org"; if (! head($url)) { die "The Server is DOWN!!!!" }
an alternative is using a get:
if (! get($url)) {
but that would fetch the content of the page. A head call uses the least resources, just telling you weather the machine is responding to that url.

Replies are listed 'Best First'.
"Up" is an ill-defined concept
by pbeckingham (Parson) on Apr 05, 2004 at 19:42 UTC

    There is a whole continuum of remote server "up" detection - from mere connectivity, through to accurate and timely responses. A machine may be in several states and conditions, and depending on quite what you are looking for, some of which can be:

    • single-user
    • multi-user
    • port 80 accepting
    • http://domain responding
    • http://domain/file responding
    • http://domain/file responding quickly enough
    It may also be that the site content is unpredictable, so a specific URL may not be something you want to check.

    Then there is a question of whether one of the unacceptable conditions might change if you retry. For example, instantaneous loads may indicate a very poor response time, but with a perfectly acceptable average.

Re^2: How to check if a website is up?
by ytjPerl (Scribe) on May 29, 2019 at 16:11 UTC
    Hi I use the head as you mentioned, but it always says the server being down with the successful URL.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://342567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-18 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found