Link to home
Start Free TrialLog in
Avatar of NovoNordisk
NovoNordisk

asked on

System Status Page

Hi guys,

Im fairly new to php and I need your expertise!!  I have a php script that checks (pings) a server.  I do this 3 times for 3 differernt servers.  What I need to do is create a "general status page". I was thinking of this...When any of the 3 servers are down, a file is written to the web server.  Then on the general status page I could have something that checks for the existence of that one file.  If it exists then it will display a particular picture, if it doesnt exisit it will display another picture.  This means that should one server be down, the file will be created and the "general" status indicator will change.  Hope that makes sense and hope someone can help!!

Thanks!
Avatar of gruntar
gruntar

You could create a simple table in your database with server names and status column. Then, when checking status you could just change status of particular server if needed.

To show status of those servers, you would just fetch server names and show proper images.

Hope that helps
Avatar of NovoNordisk

ASKER

Good idea but I dont really want to use a DB.  I already have a script that displays the status of given servers, but I just need to generalise the status of them.  So if when one of those servers are down I create a file, then I can check for the existance of that file - somehow!!!

to check existance of file do it like this

if (file_exists($filename)) {
   // do something
}

Why are you trying to do this "hard" way?

>> So if when one of those servers are down I create a file..
Why only then? why don't you have one file for each server and then you just replace status. Do you delete those files?

Give us more info..
I dont see it as being a "hard" way.  All I want is a basic status page and an advanced one.  If one of the checks on the advanced page fails, then that should affect the basic status page.  Ive just worked out how to create a file, delete it and check it, and it works OK, so unless you have a better way of doing this I might leave it as this!?
ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or to use an image, instead of:

  $status ($parts[1] == "Up") ? "Online" : "Offline";
  echo "SERVER: ".$parts[0]." is ".$status."<br>\n";

use something like:

  $status ($parts[1] == "Up") ? "image1.jpg" : "image2.jpg";
  echo "<img src=\"$status\"><br>";

The method i have shown tracks all servers, so the log file might contain something like

1|UP
2|Down
3|Up

Then when it comes to displaying the status the check is made for all of them, this behaviour can be modified if needed.