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!!

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
NovoNordiskAuthor Commented:
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..
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

NovoNordiskAuthor Commented:
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!?
You could take an approach line this (for the sake of example i have just used fsockopen with 3 random domains).

Writing to the file:

$server[1] = (@fsockopen("",80)) ? "Up" : "Down";
$server[2] = (@fsockopen("",80)) ? "Up" : "Down";
$server[3] = (@fsockopen("",80)) ? "Up" : "Down";

foreach ($server as $key => $var) {
 $filecontents[] = "$Key|$var";

$hanlde = fopen("yourstatsfile.txt","w");

Displaying status:

if (file_exists("yourstatsfile.txt")) {
 $contents = file("yourstatsfile.txt");
 foreach ($contents as $line) {
  $parts = explode("|",$line);
  $status ($parts[1] == "Up") ? "Online" : "Offline";
  echo "SERVER: ".$parts[0]." is ".$status."<br>\n";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day 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


Then when it comes to displaying the status the check is made for all of them, this behaviour can be modified if needed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.