Last Modified 5/15/12 by Akensai
A few days ago I came across a need to have a script to ping an IP:Port to see if a list of machines where online or offline. The basis for this was for a list of about 60 dedicated servers that I wanted to be able to load a page to see if any where down. After a few hours of research I came up with the following which will ping an IP and Port then change the text color to represent online or offline.
The script is very simple (don't forget to add the php tags):
// Script by Akensai
if (!$socket = @fsockopen("YOUR.IP.HERE", 80, $errno, $errstr, 30))
For those of you unaware of how PHP works, the script will actually mask your IP:Port that is queried, so no worries on someone finding the open port!
This can be used for just about anything, not just web. I use it to monitor a few FTP servers (port 21) and another for a couple of game servers. The possibilities are pretty much endless.