Results 1 to 5 of 5
-
04-29-2005, 05:17 AM #1Web Hosting Master
- Join Date
- Feb 2003
- Posts
- 560
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, $errstr, 30);
if (!$fp)
{
$i++;
print "Failed to connect $i [$errno]: $errstr $date\n";
}
else
{
fclose($fp);
}
flush();
}
?>
PHP Code:<b>Warning</b>: fsockopen(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in <b>/home/httpd/vhosts/domain.net/httpdocs/test.php</b> on 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</b> on line <b>8</b><br />
Failed to connect 1 [115]: Operation now in progress Fri Apr 29 02:10:04 PDT 2005<br>
Off Topic Web Forum - A forum for talking about anything!!
N.Z. Webmaster Community - Are you from New Zealand? Well signup to our forum!!!!
-
04-29-2005, 07:39 AM #2Aspiring Evangelist
- 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, $errstr, 30);
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.
-
04-29-2005, 08:15 PM #3Web Hosting Master
- Join Date
- Feb 2003
- Posts
- 560
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 thoughOff Topic Web Forum - A forum for talking about anything!!
N.Z. Webmaster Community - Are you from New Zealand? Well signup to our forum!!!!
-
04-30-2005, 06:38 PM #4New Member
- Join Date
- Apr 2005
- Posts
- 1
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.
-
04-30-2005, 07:11 PM #5Web Hosting Master
- Join Date
- Feb 2003
- Posts
- 560
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!!!!