This is a pretty basic uptime checker I just put together. You will need: database, knowledge of programming(not lots of knowledge) for this I created a api.php file so you can use it as a api, call the check.
API.PHP code:
<?php mysql_connect('host', 'username', 'password') or die(mysql_error());
mysql_select_db('database');
$query = mysql_query('SELECT * FROM checks WHERE
ip="'.$_GET['ip'].'" AND
owner`="'.$_GET['owner'].'"');
function ping($host, $port, $timeout) {
$tB = microtime(true);
$fP = fSockOpen($host, $port, $errno, $errstr, $timeout);
if (!$fP) { return "down"; }
$tA = microtime(true);
return round((($tA - $tB) * 1000), 0)." ms";
}`
` while($row = mysql_fetch_assoc($query))
{
$em = $row['notification_email'];
$server = $row['ip'];
$port = $row['port'];
$last_status = $row['status'];
//if($last_status=='ON') { echo 'Last checked: <font color="green">Online</font>'; } else { echo 'Last checked: <font color="red">Offline</font>'; }
$curr_status = ping($server,$port,10); // server ip: $server, server port: $port, how long till timeout: 10 (you can change it)
if($curr_status == "down")
{
echo "<font color='red'>Offline</font>"; // offline? oh noes
mysql_query("UPDATE `checks` SET `status` = 'OFF' WHERE `checks`.`id` =".$row['id'].";");
}
else
{
echo "<font color='green'>Online</font>"; // online? oh yeah :D
mysql_query("UPDATE `checks` SET `status` = 'ON' WHERE `checks`.`id` =".$row['id'].";");
}
}
//mail($em, "Notification from System", "Your server/website/ect looks like its {$curr_status}"); optional
?>`
now what this does is, first of all you would visit myurl/api.php?ip=ip&owner=admin(or whatever username you set in database) then it would check the result, now for database, you need to create a table called checks, structure it like this(id = auto insert):
img src="http://puu.sh/1BaIg" alt="img-01-tutorial" />
For some sample content I just put:
img src="http://puu.sh/1BaIU" alt="img-02-tutorial" />
Now, if I were to visit: myurl/api.php?ip=127.0.0.1&owner=admin it would ping using the ping function as in the code, now you have a option to email the statuses to the client/yourself/ect.
For every IP you want to check you need to add it into database, then I'd suggest making a CRON job to check statuses every * minutes(ex: 30 minutes or 1 hour) and do the api call for the users service/website/ect.
Thus being able to have a very basic checking system, not the best I know but its a good start for some people who want to make their own.
I hope you liked this guide, have fun.