Results 1 to 5 of 5
  1. #1

    advanced error. Need some advise from experts

    Hi All,

    I have built a pretty simplistic web site monitoring script however, with this simple script it gives me false alerts. quite often at the same time of day every day. Okay here is the script im using to duplicate the error:

    PHP Code:
    <?
        $date 
    exec("date");
        
        while (
    1)
            {
            
    $fp fsockopen("domain.com"80$errno$errstr30);
            
            if (!
    $fp)
                {
                
    $i++;
                print 
    "Failed to connect $i [$errno]: $errstr $date\n";
                }
            else
                {
                
    fclose($fp);
                }
            
            
    flush();
            }
    ?>
    Pretty simple huh... Now every about 1-30 minutes (just seems to be at random) I get the following error (repeated sometimes upto 10 times):

    PHP Code:
    <b>Warning</b>:  fsockopen(): php_network_getaddressesgetaddrinfo failedNo address associated with hostname in <b>/home/httpd/vhosts/domain.net/httpdocs/test.php</bon line <b>8</b><br />
    <
    br />
    <
    b>Warning</b>:  fsockopen(): unable to connect to mars.4dwebhosting.com:80 in <b>/home/httpd/vhosts/domain.net/httpdocs/test.php</bon line <b>8</b><br />
    Failed to connect 1 [115]: Operation now in progress Fri Apr 29 02:10:04 PDT 2005<br
    If would be greatly appriciated if anyone could help or even suggest where i start... I will provide any information needed just let me know what you think.
    Off Topic Web Forum - A forum for talking about anything!!
    N.Z. Webmaster Community - Are you from New Zealand? Well signup to our forum!!!!

  2. #2
    Join Date
    May 2004
    Posts
    398
    You are causing an infinite loop in opening sockets with the server..

    I suggest removing the while loop... you don't need to go infinite times checking server.. You only need to put it in a cron job..

    New code will be:

    PHP Code:
    <?
        $date 
    exec("date");
        
            
    $fp fsockopen("domain.com"80$errno$errstr30);
            
            if (!
    $fp)
                {
                    print 
    "Failed to connect [$errno]: $errstr $date\n";
                }
            else
                {
                
    fclose($fp);
                }
            
            
    flush();
    ?>
    Last edited by almahdi; 04-29-2005 at 07:45 AM.

  3. #3
    yeah i had it in a infinate loop just to test...

    I think i have figured it out... In /etc/resolve.conf i have changed the name servers and it seems to be stable... I will keep monitoring it.

    thanks for your reply though
    Off Topic Web Forum - A forum for talking about anything!!
    N.Z. Webmaster Community - Are you from New Zealand? Well signup to our forum!!!!

  4. #4
    Definately a nameserver issue. If you dont expect the ip to change often, you could always add an entry into your /etc/hosts file so that you dont need to depend on the dns servers.

  5. #5
    thanks tehnoob. that is a good backup solution ;-)

    it does seem to have fixed it (updating the resolve.conf) so im real happy! this has been a bug in my monitoring script (sometimes my cellphone would beep at 4am!!!!) for over 6 months!!!
    Off Topic Web Forum - A forum for talking about anything!!
    N.Z. Webmaster Community - Are you from New Zealand? Well signup to our forum!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •