Besides all of the suggestions where LWP::Simple are implemented you can also take a sniglet out of one of my scripts. This won't check the content itself but will check to see if the server in question is serving pages at all:

use Socket; : : # skip a few lines of a very large script : : sub portCheck { my ($host,$port)=@_; my ($iaddr,$paddr,$proto,$line); + $iaddr=inet_aton($host) or die "Could not aton!"; $paddr=sockaddr_in($port,$iaddr); $proto= getprotobyname('TCP'); socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; my $res=connect(SOCK, $paddr); + return 1 if $res; return 0; + + }
You would invoke it as in the following example:
: : : portCheck("www.mysite.com",80) or die "Server not serving!"; : :

If you want to check the content itself to make sure it hasn't been hacked or otherwise horribly modified then you might want to use LWP::Simple and friends runnng it one time when you know that A) the site is up and B) the page itelf is intact, generate an MD5 sum or some other fingerprint of your choosing and store that someplace for later comparison.

The sniglet above comes out of a very old script that I deployed a long time ago and it runs against several sites that I have interest in (clubs I belong to, my own web site, former customers of mine, etc.) and pages me if the site is unreachable so I can make the proper notifications.

I plan on overhauling it though given I have learned many better ways of doing things that the script does now which is why it hasn't been posted here in its entirety.


In reply to Re: How to check if a website is up? by blue_cowdawg
in thread How to check if a website is up? by anev

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.