Jump to content

[SOLVED] Server Status Script


TomBullock

Recommended Posts

Hello everyone.

Im just in the middle of building my website and i need a script that shows my users if the radio server is online or offline.

Prefferable saying 'Online' in green when on, and 'Offline' in red when its off.

Ive honestly been looking for ages, i tried up to about page 15 of Google results, many forums,  and no luck at all.

Im hoping this is where i can finnally get this script  :)

Please can anyone help me?

 

Many thanks

Tom Bullock  :)

Link to comment
Share on other sites

Radio server?

 

<?php

//Get this from somewhere ??
$status = 

if($status == 'on') {
  echo '<p style="color: green;">Online</p>';
}
else if($status == 'off') {
  echo '<p style="color: red;">Offline</p>';
}
else {
  echo 'Some error...';
}
?>

 

If the above simple code wasn't what you were wanting help for you must post more detail about the "radio server", how you can communicate with it, what it runs ect. :)

Link to comment
Share on other sites

There is no standard script to check the status of a "radio server" because "radio server" is no standard thing / definition. I don't know what your radio server do.

 

That's the only tough part of this script. How to get the actual status of the server (cf. //Get this from somewhere? $status = ). Your server must run some software and since it has something to do with radio it maybe stream / broad cast stuff? That software need to have a build in function which tells the status of the server.

 

More info....

Link to comment
Share on other sites

Ive just been informed that we've had a change of plan.

It is now a webserver that we want to show the status of.

The same applies as in 'Online' green, 'Offline' red.

The i.p address is 81.97.108.170 and the port number is 80.

 

If you need anymore info, please ask.

 

Many thanks

Tom Bullock  :)

Link to comment
Share on other sites

Well if the webserver is online it should be able to answer a http request, so all you need is to send a http request to the server and see if you get an answer. I'm no expert when it comes to this, but I guess you have to look into cURL.

Link to comment
Share on other sites

Yes, the same principal, but just a script where i can enter the i.p address and port number of my server into the script and when the server is online it says 'Online' in green and when it is offline is says 'Offline' in red.

 

Many thanks

Tom Bullock  :)

Link to comment
Share on other sites

<?php

  $server  = "127.0.0.1";
  $port   = "80";
  $timeout = "10";

  if ($server and $port and $timeout) {
    $verbinding =  @fsockopen("$server", $port, $errno, $errstr, $timeout);
  
  }
  if($verbinding) {
    echo "<img src='./images/on.gif'>Website is online<br>";
  }
  else {
    echo "<img src='./images/off.gif'>Website is offline<br>";
  }
fclose($verbinding);
?>

Link to comment
Share on other sites

<?php

  $server  = "127.0.0.1";
  $port   = "80";
  $timeout = "10";

  if ($server and $port and $timeout) {
    $verbinding =  @fsockopen("$server", $port, $errno, $errstr, $timeout);
  
  }
  if($verbinding) {
    echo "<img src='./images/on.gif'>Website is online<br>";
  }
  else {
    echo "<img src='./images/off.gif'>Website is offline<br>";
  }
fclose($verbinding);
?>

 

Yes that is exactly what im looking for except instead of having images to display the status, i need it to be text.

 

Many thanks

Tom Bullock  :)

Link to comment
Share on other sites

<?php

  $server  = "127.0.0.1";
  $port   = "80";
  $timeout = "10";

  if ($server and $port and $timeout) {
    $verbinding =  @fsockopen("$server", $port, $errno, $errstr, $timeout);
  
  }
  if($verbinding) {
    echo "<img src='./images/on.gif'>Website is online<br>";
  }
  else {
    echo "<img src='./images/off.gif'>Website is offline<br>";
  }
fclose($verbinding);
?>

 

Yes that is exactly what im looking for except instead of having images to display the status, i need it to be text.

 

Many thanks

Tom Bullock  :)

 

ok just use this and change the text as wanted

 

<?php

  $server  = "127.0.0.1";
  $port   = "80";
  $timeout = "10";

  if ($server and $port and $timeout) {
    $verbinding =  @fsockopen("$server", $port, $errno, $errstr, $timeout);
  
  }
  if($verbinding) {
    ?>
<font color="green">Online</font>
<?
  }
  else {
    ?>
<font color="red">Offline</font>
<?
  }
fclose($verbinding);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.