celestine
11-17-2003, 02:14 AM
Hi all.
I run a website that uses several file servers to host some downloadable files. The problem is sometimes the file servers go off and I don't know until very much later. I want to make a script that can ping the list of these servers to see if they are online.
I wrote a remote ftp function to ftp_login and if ftp_login fails, I assumed the file server is offline. Is this concept correct? I ran the script and all my results returned were "online"
I'm also in a bit of a fix, most of the file servers are running on *nix servers but a couple are on NT. Will I have to do a different function for the NT servers? Here's the function code I have for the moment.
function sponsor_status($ftpadd,$ftpusername,$ftppassword)
{
// set up basic connection
$conn_id = ftp_connect($ftpadd);
// login with username and password
$login_result = @ftp_login($conn_id, $ftpusername, $ftppassword);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "<td class=\"error\"><strong>Offline</strong></td></tr>";
}
// Read flag file, success = file server online, else offline
else {
echo "<td><strong>Online</strong></td></tr>";
}
// close the FTP stream
ftp_quit($conn_id);
I run a website that uses several file servers to host some downloadable files. The problem is sometimes the file servers go off and I don't know until very much later. I want to make a script that can ping the list of these servers to see if they are online.
I wrote a remote ftp function to ftp_login and if ftp_login fails, I assumed the file server is offline. Is this concept correct? I ran the script and all my results returned were "online"
I'm also in a bit of a fix, most of the file servers are running on *nix servers but a couple are on NT. Will I have to do a different function for the NT servers? Here's the function code I have for the moment.
function sponsor_status($ftpadd,$ftpusername,$ftppassword)
{
// set up basic connection
$conn_id = ftp_connect($ftpadd);
// login with username and password
$login_result = @ftp_login($conn_id, $ftpusername, $ftppassword);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "<td class=\"error\"><strong>Offline</strong></td></tr>";
}
// Read flag file, success = file server online, else offline
else {
echo "<td><strong>Online</strong></td></tr>";
}
// close the FTP stream
ftp_quit($conn_id);