Loading ...
Sorry, an error occurred while loading the content.

Re: [bang-phpug] How to check the Site is UP or DOWN

Expand Messages
  • Anees
    Hi Vinu, Thanks for ur response!!! But Do u think it will work when the site resides on a static IP based server system structure? let me clear. wen i took
    Message 1 of 10 , Jun 13, 2007
    • 0 Attachment
      Hi Vinu,
      Thanks for ur response!!!

      But
      Do u think it will work when the site resides on a static IP based server system structure?

      let me clear.

      wen i took some space from any provider
      the IP which they are given is not the real one wer the data will store..
      so in such cases wen we check the port 80 of that IP address..it may not be exist and will giv a error in connection message.. right???


      Anees Muhammed
      ___________


      ----- Original Message ----
      From: Vinu Thomas <vinuthomas@...>
      To: bang-phpug@yahoogroups.com
      Sent: Wednesday, June 13, 2007 11:28:28 AM
      Subject: Re: [bang-phpug] How to check the Site is UP or DOWN













      Anees,



      Here's how the program would look:



      <?php

      // Your Domain to check

      $site = "www.vinuthomas. com";



      // Port to check - Default port 80 for webserver

      // You can check other ports by changing the

      // value of $port

      $port = 80;



      $fp = fsockopen($site, $port,$errno, $errstr,10) ;

      if(!$fp)

      {

      echo "Cannot connect to server";

      // you can send your notification mail here.

      }else{

      echo "Connect was successful - no errors";

      fclose($fp);

      }



      ?>



      The script connects to port 80, the default web port and sees if it

      can connect. If a connection is successful, the webserver is

      functional.



      Regards,

      Vinu

      ------------ --------- --------- -

      www.vinuthomas. com

      blogs.vinuthomas. com



      On 6/13/07, Anees <anees_muhd@yahoo. com> wrote:



      > Hi Friends,

      >

      > I want to write a script that checks a particular site is UP or not

      > if not it will display an error message to notifiy the site is down.

      >

      > Any Idea to do dis using PHP?

      > (i think we can go by sending request to the Port, but it will not be possible if the data resides in some Dynamically assigned IP system)

      > Please Help

      >

      > Anees Muhammed

      > ___________












      <!--

      #ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
      #ygrp-mlmsg table {font-size:inherit;font:100%;}
      #ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, sans-serif;}
      #ygrp-mlmsg pre, code {font:115% monospace;}
      #ygrp-mlmsg * {line-height:1.22em;}
      #ygrp-text{
      font-family:Georgia;
      }
      #ygrp-text p{
      margin:0 0 1em 0;}
      #ygrp-tpmsgs{
      font-family:Arial;
      clear:both;}
      #ygrp-vitnav{
      padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
      #ygrp-vitnav a{
      padding:0 1px;}
      #ygrp-actbar{
      clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
      #ygrp-actbar .left{
      float:left;white-space:nowrap;}
      .bld{font-weight:bold;}
      #ygrp-grft{
      font-family:Verdana;font-size:77%;padding:15px 0;}
      #ygrp-ft{
      font-family:verdana;font-size:77%;border-top:1px solid #666;
      padding:5px 0;
      }
      #ygrp-mlmsg #logo{
      padding-bottom:10px;}

      #ygrp-vital{
      background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
      #ygrp-vital #vithd{
      font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
      #ygrp-vital ul{
      padding:0;margin:2px 0;}
      #ygrp-vital ul li{
      list-style-type:none;clear:both;border:1px solid #e0ecee;
      }
      #ygrp-vital ul li .ct{
      font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
      #ygrp-vital ul li .cat{
      font-weight:bold;}
      #ygrp-vital a {
      text-decoration:none;}

      #ygrp-vital a:hover{
      text-decoration:underline;}

      #ygrp-sponsor #hd{
      color:#999;font-size:77%;}
      #ygrp-sponsor #ov{
      padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
      #ygrp-sponsor #ov ul{
      padding:0 0 0 8px;margin:0;}
      #ygrp-sponsor #ov li{
      list-style-type:square;padding:6px 0;font-size:77%;}
      #ygrp-sponsor #ov li a{
      text-decoration:none;font-size:130%;}
      #ygrp-sponsor #nc {
      background-color:#eee;margin-bottom:20px;padding:0 8px;}
      #ygrp-sponsor .ad{
      padding:8px 0;}
      #ygrp-sponsor .ad #hd1{
      font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
      #ygrp-sponsor .ad a{
      text-decoration:none;}
      #ygrp-sponsor .ad a:hover{
      text-decoration:underline;}
      #ygrp-sponsor .ad p{
      margin:0;}
      o {font-size:0;}
      .MsoNormal {
      margin:0 0 0 0;}
      #ygrp-text tt{
      font-size:120%;}
      blockquote{margin:0 0 0 4px;}
      .replbq {margin:4;}
      -->









      ____________________________________________________________________________________
      Get your own web address.
      Have a HUGE year through Yahoo! Small Business.
      http://smallbusiness.yahoo.com/domains/?p=BESTDEAL

      [Non-text portions of this message have been removed]
    • Vinu Thomas
      Anees, Most web hosting is on static IP address. In any case, in the script if you don t have to put in the IP address. Just put in the domain name of your
      Message 2 of 10 , Jun 13, 2007
      • 0 Attachment
        Anees,

        Most web hosting is on static IP address. In any case, in the script
        if you don't have to put in the IP address. Just put in the domain
        name of your site. That will resolve your domain to the ip which your
        provider gives you for the site.

        When you connect to a site on the browser, it uses the port 80 on the
        server to acccess your site. So if the port 80 for your domain is not
        accessible, that would mean that even your browser won't be able to
        show the pages of your site.

        Regards,
        Vinu

        -------------------------------
        www.vinuthomas.com
        blogs.vinuthomas.com

        On 6/13/07, Anees <anees_muhd@...> wrote:
        > Hi Vinu,
        > Thanks for ur response!!!
        >
        > But
        > Do u think it will work when the site resides on a static IP based server system structure?
        >
        > let me clear.
        >
        > wen i took some space from any provider
        > the IP which they are given is not the real one wer the data will store..
        > so in such cases wen we check the port 80 of that IP address..it may not be exist and will giv a error in connection message.. right???
        >
        > Anees Muhammed
        > ___________
        >


        --
      • Jayasurian
        hi Anees, why dont you use CURL ? Hit the url. Check the header response . Thats all :) jayasurian123... ... [Non-text portions of this message have been
        Message 3 of 10 , Jun 13, 2007
        • 0 Attachment
          hi Anees,
          why dont you use CURL ? Hit the url. Check the header response .
          Thats all :)

          jayasurian123...

          Anees wrote:
          >
          > Hi Friends,
          >
          > I want to write a script that checks a particular site is UP or not
          > if not it will display an error message to notifiy the site is down.
          >
          > Any Idea to do dis using PHP?
          > (i think we can go by sending request to the Port, but it will not be
          > possible if the data resides in some Dynamically assigned IP system)
          > Please Help
          >
          > Anees Muhammed
          > ___________
          >



          [Non-text portions of this message have been removed]
        • Anees
          hi leulogy,Jayasurian ,Vinu thanks for ur help i think i can find a good and proper solution from ur ideas thanks for ur help Anees Muhammed ... From: leulogy
          Message 4 of 10 , Jun 14, 2007
          • 0 Attachment
            hi leulogy,Jayasurian ,Vinu

            thanks for ur help
            i think i can find a good and proper solution from ur ideas

            thanks for ur help
            Anees Muhammed
            ___________


            ----- Original Message ----
            From: leulogy <leulogy@...>
            To: Anees <anees_muhd@...>
            Sent: Wednesday, June 13, 2007 10:40:55 PM
            Subject: Re: How to check the Site is UP or DOWN

            Try fetching a small page on the site in question, dont forget to set
            a timeout that is short, but not too short as to cut off the sites
            response if it happens to be busy at the moment, If your resulting
            variable is populated then it is safe to assume that the site is up,
            if the fetch fails, then it's safe to assume that the site is either
            really busy, or currently down.

            There are really several ways to go about checking a websites status.
            One way I listed above, another is to use sockets, and send requests
            as if your script was a www browser, I wrote one such sockets class,
            but it was aimed more @ sending queries to gameservers, but should
            really work for just about anything provided you know the querystring
            or data to send, and how to handle the response.

            Bottom Line, php.net manual is your friend.

            --- In php-objects@yahoogroups.com, Anees <anees_muhd@...> wrote:
            >
            > Hi Friends,
            >
            > I want to write a script that checks a particular site is UP or not
            > if not it will display an error message to notifiy the site is down.
            >
            > Any Idea to do dis using PHP?
            > (i think we can go by sending request to the Port, but it will not
            be possible if the data resides in some Dynamically assigned IP
            system)
            > Please Help
            >
            > Anees Muhammed
            > ___________
            >
            >
            >
            >
            >
            >
            >
            ______________________________________________________________________
            ______________
            > Need a vacation? Get great deals
            > to amazing places on Yahoo! Travel.
            > http://travel.yahoo.com/
            >
            > [Non-text portions of this message have been removed]









            ____________________________________________________________________________________
            Never miss an email again!
            Yahoo! Toolbar alerts you the instant new Mail arrives.
            http://tools.search.yahoo.com/toolbar/features/mail/

            [Non-text portions of this message have been removed]
          • Amit Rana
            I will not support this strategy, assuming you will be checking every 5 mins you do not want to end up eating so much bandwidth and add to server traffic. You
            Message 5 of 10 , Jun 17, 2007
            • 0 Attachment
              I will not support this strategy, assuming you will be
              checking every 5 mins you do not want to end up eating
              so much bandwidth and add to server traffic.
              You should not make GET/POST request, try for HEAD

              my 2 cents.

              --- Vinu wrote --

              Anees,

              Here's how the program would look:

              <?php
              // Your Domain to check
              $site = "www.vinuthomas. com";

              // Port to check - Default port 80 for webserver
              // You can check other ports by changing the
              // value of $port
              $port = 80;

              $fp = fsockopen($site, $port,$errno, $errstr,10) ;
              if(!$fp)
              {
              echo "Cannot connect to server";
              // you can send your notification mail here.
              }else{
              echo "Connect was successful - no errors";
              fclose($fp);
              }

              ?>

              The script connects to port 80, the default web port
              and sees if it
              can connect. If a connection is successful, the
              webserver is
              functional.

              Regards,
              Vinu



              ____________________________________________________________________________________
              Sick sense of humor? Visit Yahoo! TV's
              Comedy with an Edge to see what's on, when.
              http://tv.yahoo.com/collections/222
            • Amit Rana
              Yes, this is another good idea. There are other things you need to keep in mind when checking for website s health for eg. db is up or not, if db is up is it
              Message 6 of 10 , Jun 17, 2007
              • 0 Attachment
                Yes, this is another good idea. There are other things
                you need to keep in mind when checking for website's
                health for eg. db is up or not, if db is up is it
                responding or not (if its out of connections then even
                if db is up it might not be responding.

                ----- Original Message ----
                From: leulogy <leulogy@yahoo. com>
                To: Anees <anees_muhd@yahoo. com>
                Sent: Wednesday, June 13, 2007 10:40:55 PM
                Subject: Re: How to check the Site is UP or DOWN

                Try fetching a small page on the site in question,
                dont forget to set
                a timeout that is short, but not too short as to cut
                off the sites
                response if it happens to be busy at the moment, If
                your resulting
                variable is populated then it is safe to assume that
                the site is up,
                if the fetch fails, then it's safe to assume that the
                site is either
                really busy, or currently down.

                There are really several ways to go about checking a
                websites status.
                One way I listed above, another is to use sockets, and
                send requests
                as if your script was a www browser, I wrote one such
                sockets class,
                but it was aimed more @ sending queries to
                gameservers, but should
                really work for just about anything provided you know
                the querystring
                or data to send, and how to handle the response.



                ____________________________________________________________________________________
                Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
                http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
              • Anees
                hi Amith please let me know how i can do the same with HEAD. Anees Muhammed ... From: Amit Rana To: bang-phpug@yahoogroups.com Sent:
                Message 7 of 10 , Jun 17, 2007
                • 0 Attachment
                  hi Amith

                  please let me know how i can do the same with HEAD.


                  Anees Muhammed
                  ___________


                  ----- Original Message ----
                  From: Amit Rana <amitrana77@...>
                  To: bang-phpug@yahoogroups.com
                  Sent: Monday, June 18, 2007 9:57:19 AM
                  Subject: [bang-phpug] Re: How to check the Site is UP or DOWN













                  I will not support this strategy, assuming you will be

                  checking every 5 mins you do not want to end up eating

                  so much bandwidth and add to server traffic.

                  You should not make GET/POST request, try for HEAD



                  my 2 cents.



                  --- Vinu wrote --



                  Anees,



                  Here's how the program would look:



                  <?php

                  // Your Domain to check

                  $site = "www.vinuthomas. com";



                  // Port to check - Default port 80 for webserver

                  // You can check other ports by changing the

                  // value of $port

                  $port = 80;



                  $fp = fsockopen($site, $port,$errno, $errstr,10) ;

                  if(!$fp)

                  {

                  echo "Cannot connect to server";

                  // you can send your notification mail here.

                  }else{

                  echo "Connect was successful - no errors";

                  fclose($fp);

                  }



                  ?>



                  The script connects to port 80, the default web port

                  and sees if it

                  can connect. If a connection is successful, the

                  webserver is

                  functional.



                  Regards,

                  Vinu



                  ____________ _________ _________ _________ _________ _________ _

                  Sick sense of humor? Visit Yahoo! TV's

                  Comedy with an Edge to see what's on, when.

                  http://tv.yahoo com/collections/ 222












                  <!--

                  #ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
                  #ygrp-mlmsg table {font-size:inherit;font:100%;}
                  #ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, sans-serif;}
                  #ygrp-mlmsg pre, code {font:115% monospace;}
                  #ygrp-mlmsg * {line-height:1.22em;}
                  #ygrp-text{
                  font-family:Georgia;
                  }
                  #ygrp-text p{
                  margin:0 0 1em 0;}
                  #ygrp-tpmsgs{
                  font-family:Arial;
                  clear:both;}
                  #ygrp-vitnav{
                  padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
                  #ygrp-vitnav a{
                  padding:0 1px;}
                  #ygrp-actbar{
                  clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
                  #ygrp-actbar .left{
                  float:left;white-space:nowrap;}
                  .bld{font-weight:bold;}
                  #ygrp-grft{
                  font-family:Verdana;font-size:77%;padding:15px 0;}
                  #ygrp-ft{
                  font-family:verdana;font-size:77%;border-top:1px solid #666;
                  padding:5px 0;
                  }
                  #ygrp-mlmsg #logo{
                  padding-bottom:10px;}

                  #ygrp-vital{
                  background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
                  #ygrp-vital #vithd{
                  font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
                  #ygrp-vital ul{
                  padding:0;margin:2px 0;}
                  #ygrp-vital ul li{
                  list-style-type:none;clear:both;border:1px solid #e0ecee;
                  }
                  #ygrp-vital ul li .ct{
                  font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
                  #ygrp-vital ul li .cat{
                  font-weight:bold;}
                  #ygrp-vital a {
                  text-decoration:none;}

                  #ygrp-vital a:hover{
                  text-decoration:underline;}

                  #ygrp-sponsor #hd{
                  color:#999;font-size:77%;}
                  #ygrp-sponsor #ov{
                  padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
                  #ygrp-sponsor #ov ul{
                  padding:0 0 0 8px;margin:0;}
                  #ygrp-sponsor #ov li{
                  list-style-type:square;padding:6px 0;font-size:77%;}
                  #ygrp-sponsor #ov li a{
                  text-decoration:none;font-size:130%;}
                  #ygrp-sponsor #nc {
                  background-color:#eee;margin-bottom:20px;padding:0 8px;}
                  #ygrp-sponsor .ad{
                  padding:8px 0;}
                  #ygrp-sponsor .ad #hd1{
                  font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
                  #ygrp-sponsor .ad a{
                  text-decoration:none;}
                  #ygrp-sponsor .ad a:hover{
                  text-decoration:underline;}
                  #ygrp-sponsor .ad p{
                  margin:0;}
                  o {font-size:0;}
                  .MsoNormal {
                  margin:0 0 0 0;}
                  #ygrp-text tt{
                  font-size:120%;}
                  blockquote{margin:0 0 0 4px;}
                  .replbq {margin:4;}
                  -->









                  ____________________________________________________________________________________
                  Choose the right car based on your needs. Check out Yahoo! Autos new Car Finder tool.
                  http://autos.yahoo.com/carfinder/

                  [Non-text portions of this message have been removed]
                • Amit Rana
                  If you want to go the HEAD way: man curl Another way: www.php.net/fopen ...
                  Message 8 of 10 , Jun 18, 2007
                  • 0 Attachment
                    If you want to go the HEAD way:
                    man curl

                    Another way:
                    www.php.net/fopen

                    --- Anees <anees_muhd@...> wrote:

                    > hi Amith
                    >
                    > please let me know how i can do the same with HEAD.
                    >
                    >
                    > Anees Muhammed
                    > ___________




                    ____________________________________________________________________________________Ready for the edge of your seat?
                    Check out tonight's top picks on Yahoo! TV.
                    http://tv.yahoo.com/
                  Your message has been successfully submitted and would be delivered to recipients shortly.