Web server information from the web.
Wondered if there was a way to get information about a web server from the web. After researching, I found an abandoned article with a script that fit the bill. From a few lines, the script has expanded quite nicely. The script is becoming more and more popular. You can get more information at: http://www.instructables.com/id/Simple-linux-commands-from-a-web-page/
Reprint from an earlier post that applies.
One of the things I get dismayed with is when going to the bookmarks and a link is dead. Also too, If I have several web servers I like to access, it would be nice to know if the site is up before I try to go to that site. Here we will use a small amount of PHP (another web language) that can be used with HTML just like javascript. Generally PHP is used only on servers, but you can run a local copy of it. PHP is available for most systems.
Bookmarks really do not carry that much information per se. The above example only has one entry for sake of simplicity. What I would really like to know is if that site is still good, that is up and running. So I added an extra column for the server status.
Again just one entry for sake of simplicity. Now before I even go to the site I can tell whether it is available. In the real world, you will probably will have many entries and many servers. For example, one page I use lists several servers, but some sites are virtual so they will use the same ipaddress. There is no need to relist that information. I also want to be able to see all the servers at once to know their status.
Typo1 is offline. That is ok, because I know the server box is turned off. If it is supposed to be up then, that server needs to be attended to. You could also do this with your favorite servers (i.e. Facebook and etc.). So you have another great simple management tool. Oh yes, I said we would be using PHP and HTML. Here is the abbreviated code:
su.php:
[code]
<html>
<body>
<hr>
<center>
<h2>
Bookmarks
</h2>
</center>
<hr>
<table border="1" cellpadding="10">
<tr>
<td>
Ipaddress
</td>
<td>
Site (and link)
</td>
<td>
Description
</td>
<td>
Server status
</td>
</tr>
<tr>
<td>
192.168.1.31
</td>
<td>
<a href="http://oesrvr1">Offshore Educators</a>
</td>
<td>
School site
</td>
<td>
<?php
if (fsockopen('oesrvr1', 80)){
echo('The server is online');
} else{
echo('The server is offline');
}
?>
</td>
</tr>
</table>
</body>
</html>
[/code]
Note: The code is being run on a server and not a local machine. If you want an update, you will have to reload the page.
Comments
Post a Comment