Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-13-2003, 11:21 AM #1
- Join Date
- Apr 2003
- Seoul, Korea
- Thanked 0 Times in 0 Posts
checking the target server is on or off
$read = @fopen("http://22.214.171.124:8500","r" );
The above code is intended for nex two conditions.
If the remote target server is dead, go to sorry.php.
If the remote target server is alive, go to the server.
But the result of the above code is;
(1) when the target server is off, the check page try to find the target
server for a long time, and it finally says it can't find the target server.
(2) when the target server is on the way of booting, the check page goes to
(3) when the target server is fully booted, the check page goes to the
target server page.
The problem happens when the target server is off.
Do you have more correct code for it?
Thanks in Advance
09-13-2003, 02:35 PM #2
(2) when the target server is on the way of booting, the check page goes to sorry page.
There's no way to detect if the server is online if the server isn't connected to the net yet. It will always go to the sorry page
Try this code
//Autor: Antonio Leal Elizondo 12/Ago/03
// This script pings a machine and checks if it's alive or not.
// It can run a command in case the machine is not answering
$unix = 1; //Put 1 here if you are using a UNIX machine
$windows = 0; //Put 1 here if you are using a Windown machine
$unix = (bool) $unix;
$win = (bool) $windows;
$count= 3; // Number of times to ping
$host = "126.96.36.199"; // IP of the remote server
$find = "Tiempo de espera agotado"; // String to look for
$shell= "pwd"; // Command to execute if the machine does not answer.
$findUnix="0 packets received";
// Replaced nonvalued characters
$host= preg_replace ("/[^A-Za-z0-9.]/","",$host);
//Check the IP
$comm="ping -t $count $host";
$comm="ping -n $count $host";
// system("killall ping");// Kill all pings in case they exist.
echo "\n An error has occured at $host\n ";
echo date("D F Y h:i a");
echo "\n Executng auxiliary command \n ";
echo "\n There are no problems with $host \n";
echo date("D F Y h:i a"). "\n" ;