MyBB Community Forums

Full Version: Writing a server uptime monitoring script, need advice on best method.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am finishing up my script for checking if a server is online or not but I am not sure the best way of determining whether or not the server is online or not. I am trying to reduce all false alarms so I have the script check the server 3 ways: ICMP(single ping), curl(HTTP response code), and wget(web/error page exists or not).

So here are the methods I've come up with:

Scoring Method
    score=0
    if ping = successful
      score+1
    if curl != 000
      score+1
    if wget = successful
      score+1
    if score >= 2
      online
    else
      offline

Cross-check Method
    if ping = successful
      online
    elseif curl != 000
      online
    elseif wget = successful
      online
    else
      offline

Double-check Method
    if ping = successful & curl != 000 & wget = successful
      online
    else
      if ping = successful & curl != 000 & wget = successful
        online
      else 
        offline
So what method do you think would be best? If you think they are all overkill that's fine also. I'm currently using the cross-check method without any issues but I'm wondering if the scoring method wouldn't be better because it will always check all 3. The double-check method seems the easiest to fail because it's all or nothing but it ensures both your network is working and your website is online.
Scoring would be your best method. As you require all tests to pass to to be online. I would however have the max score be 4 (doing the ping twice) and requiring a score of 3 or more (to prepare for a dropped ping. If both pings fail it'll score 2 Smile

Method 2 won't work as it may fail the Curl test (setting it offline) but then pass the wget test (overwriting the offline, giving a false result)

Method 3 seems a bit complex for this task.
For method one I do like the idea of multiple pings, I will see how difficult it would be to code that, I might have to start from scratch. Sad

For method 2, if it fails the ping test and the curl test I doubt it would pass the wget test. Wink
If you want mostly to know if your server is active you can rely on PING as your primary information, but if you want to know if your server is serving HTTP content you should consider relying more on WGET or CURL.

In my opinion using both CURL and WGET is redundant and just using more ressources for no more usefull informations.

So my logic would be more like :
status = offline;
if (ping == successful){
      status = active;
      if (wget == successful){
            status = serving_pages;
      }
}


(2011-05-02, 12:23 PM)exdiogene Wrote: [ -> ]If you want mostly to know if your server is active you can rely on PING as your primary information, but if you want to know if your server is serving HTTP content you should consider relying more on WGET or CURL.

In my opinion using both CURL and WGET is redundant and just using more ressources for no more usefull informations.

So my logic would be more like :
status = offline;
if (ping == successful){
      status = active;
      if (wget == successful){
            status = serving_pages;
      }
}

This is exactly what I'm using now (except replace wget with curl) so I might just stick with it. Smile