Need a online/offline serverstatus script

snaaps

Verified User
Joined
Jan 29, 2005
Messages
230
Location
Netherlands
Hi,

I,Am searching for a script that checks multiple severs on multiple ports.
When all servers are online then show: all servers seem apears online.

When 1 of the servers (ip or port) not respond to the check then only show this sever as offline on the server status page.

The script must run with a cronjob update every 3 or 5 minutes.

All server status, noc, online/offline script that i can find show all servers on the server status page, i don,t want that!
I only want to show if there is a problem with 1 of the servers, otherwise show all server are online.

Does anybody knows or this exist or want to make a litle script for me?
(i can pay with paypal)
 
What do you want to check?

We've started one that simply check http; it's easy enough. We expect to put ours into the public domain.

Of course it needs to be run on a separate system. We can do this from our office since we have linux desktops running 24/7. How/where would you expect to run it?

We also expect that we'll add mail and other services, and once we've got it running we'll offer it at no charge and charge only for people who want to use our service for the checking.

Jeff
 
Keep in mind that many times the ports can be open and the software appear to be running but not actually responding to requests. Like to check httpd you would need to send a requests and actually get a response header, not just check to see if port 80 is open.
 
I want to check: http, ftp, pop3, smtp and the mysql ports on all our servers.

If one ore more ports failed then show on the stats page:
FTP, HTTP seems te be offline on server 5.
HTTP seems to be offline ons server 10.
Please see our news update page for more information about this downtime, link blablabla


If there are no problems with the server then the stats page shows:
There are problems with our servers on this moment.
If you have still problems with the connection, please contact us and use our contactpage

I have tried to edit the www.sillydns.com statusmon script, but i not so good with scripting, i can edit this script to work problerly as above.
this script used a cronjob and store the uptimes to a database, only i want to change is the status.php page so it will only show: all servers are online, or otherwise show the servers that seem to be offline and nothing more!
 
Ive taken a look and made some changes, it isn't exacly what you need I think, but maybe this helps you on the way:

Changes from line 86 to line 141 (in the original file):

PHP:
        <?php
    foreach($servicelist as $key=>$value)
    {
        $services[] = $value;
        printf("<td class=title>%s</td>",$value."  ");
    }
    if ($LastUpdateFmt == 'Actual') {
    echo "<td class=title>Last Update</td>";
    }
    else {
    echo "<td class=title>Time Since Update</td>";
    }
    echo "</tr>";
          foreach($serverlist as $key=>$value) { ?>

          <tr>
          <td class=detail>
          <?php
          $info = $server->getInfo($key);
          if ($alertraid && $info['alertra']) echo "<A onclick=\"NewWindow(this.href,'name','450','400','no');return false;\" title=\"View uptime history\" href=\"http://uptime.alertra.com/uptime.php?pin=".$alertraid."&abrv=".$info['alertra']."&color1=white&color2=navy&stitle=UPTIME%20DATA\">$value</a></td>";
          else echo "<A onclick=\"NewWindow(this.href,'name','450','400','no');return false;\" title=\"View uptime history\" href=\"reporter.php?serverid=$key\">$value</a></td>";
          $i = 0;
          foreach($servicelist as $skey=>$svalue)
          {
              $status = $service->getStatus($key,$skey);
              if ($status == 1) {
              }
              elseif ($status == 0) {
                  $offline[$i] = true;
              }
              $i++;
          }
          $time = $server->getUpdateTime($key);

        if ($time == '0000-00-00 00:00:00') {$time = "Never Updated";}
          else {
            if ($LastUpdateFmt == 'Actual') {
            $time = date("m/d/Y h:i a", strtotime($time));
            }
            else {
            $time = TimeAgo(strtotime($time),strtotime($nowdate));
            }
          }

          if (empty($offline)) {
              echo '<td colspan="6">There are no problems!</td>';
          }
          else {
              echo '<td colspan="6">The following services are down:';
              foreach ($offline as $nr => $value) {
                  echo ' '.$services[$nr];
              }
              echo '</td>';
          }
          unset($offline);

          ?>
        <td class=detail><span style="color:black; font-weight: bold; font-family:verdana;font-size:10px">
        <?php echo $time; ?></span></td>
        </tr>

        <?

          }
          echo "</table>";
        }
         else {

        echo "No servers being monitored currently.";
        }
?>

This shows something like:

domain1.tld The following services are down: https mysql 11 mins 40 secs
domain2.tld There are no problems! 11 mins 40 secs
 
Keep in mind that many times the ports can be open and the software appear to be running but not actually responding to requests. Like to check httpd you would need to send a requests and actually get a response header, not just check to see if port 80 is open.
Of course. We actually look for a page we know is on the server. We wget it and then check the contents.

Jeff
 
Thanks, but so far i already have edit it my self.
Problem is that it outputs al servers on de status.php page and not only the servers that are offline or if all servers online show only: all servers are online.
 
Hi There!

I have already a other and much better soulition!
Whe used nagios for monitoring our servers.

So now i lett the server wget the downtime page of nagios (http://ip.adres.nagios.server/nagios/cgi-bin/status.cgi?servicestatustypes=28)
Then i will lett the server edit this downloaded page with sed so you will get a better looking status page that will only show servers if they seem to be offline, if al server are up than it will show: there are no problems on this moment, all servers seems to be up!

I wget and edit this every 5 minutes.
So for example you will get this:
http://ccchosting.nl/serverstatus.html


Now i have one litle problem (i have not searching yet)
there is a text: x Matching Service Entries Displayed
(x stands for how many services has been found offline)

Now i want to change this wit the bash if command:
if 0 then echo: there are no problems on this moment, all servers seems to be up!
else echo: x services seems to be offline, a sms is send to our people.

(i am not know how to work with the if command and the 0 or other number results)
 
Last edited:
Back
Top