Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking status of remote server 1

Status
Not open for further replies.

geuis

Programmer
Jan 26, 2003
7
US
I am trying to write a tool for a website that will check to see if a remote server is up or down. Depending on the status, the web page will then report if the server is on or offline.
I would like to make this so that the page checks when a user loads the page, instead of having the script running as a constant background process, as the folks who run the webserver probably wouldn't appreciate adding major usage to the server cpu.

Any help is really, really appreciated. Thanks!
 
You could ping the server, and redirect the output to a text file, look in the text file to see if you're getting the right results, and echo the appropriate response.

On linux redirect to a filename combining the time, and the process id for uniqueness ($$-$now.txt)

You could also look at Net::ping which might not require the use of a text file. Hvaen't used it yet, but it couldn't hurt to look

Cheers
Paul
 
use Net::ping;
$host = Net::ping->new("icmp");

if ($host->ping($server, 5)) {
print "$server is up\n";
} else {
print "$server is down\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top