Filed Under (Gadgets/Widgets, projects, software) by Simon on June-18-2007

servermonitorsample.jpgThis is my first google gadget I have created a simple gadget which simply polls a URL every 5mins and displays the result.

It is designed to work with a server side script that will return a small text string that will be useful to display. You can actually set up a number of URLs to monitor.

Download a copy here: ServerMonitor2

For my purposes it displays, the hostname and server load of 2 applications, these applications are in a server cluster, so the hostname tells me which node the application is running on, and the system load is a good indicator of usage.

Server Side Code

The server side code can be as simple as this:
< ? php
$host = trim(`hostname`);
$fiveMinAvg = trim(`uptime | cut -f 5 -d ,`);
echo $host . ' (' . $fiveMinAvg .')';
?>

Let me know if you like it!

More Information including new development, Feature wishlists.



Comments
rory on August 7th, 2007 at 8:33 am #

Server Monitor for Dummies

Hi
Great idea, want to use it, but dont know how.
How do I go about putting the php code onto my site ? Is it embedded in my index html file or as a seperate php file ?
Sorry, dummies guide would really help….
Thanks

Simon on August 7th, 2007 at 10:06 am #

Hi Rory,
It should be a separate php file.
The output of the php script should be only what you want to see in the gadget.
So using above code example create a file named for example “server_check.php” and it’s only contents should be the 5 lines of code.
and the output of that php page in a browser should look like:
Hostname (1.01)
Thanks,
Simon

Post a comment
Name: 
Email: 
URL: 
Comments: