2011-05-02, 05:57 AM
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
Cross-check Method
Double-check Method
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.