How to make a server check it's own availability on the web?

0

Just a quick question – my server is running at my house serving webpages at http://www.javawag.com/. The problem is that my home internet connection keeps dropping randomly - for about 10 minutes at a time. This is only an intermittent problem and will go away soon I hope. However, my server doesn't recover properly - when the connection comes back, I can still access it at 192.168.0.8 (locally) without any issue, but at http://www.javawag.com/ there's no reply.

(Just an aside - my home internet connection is dynamic ISP, the domain www.javawag.com points to javawag.dyndns.org which in turn points to my IP, updated every minute by ddclient on the server).

Is there some way for the server to check if it's accessible from the outside world periodically, and if not restart Apache/reboot? Oh, and if I reboot the problem fixes itself also!

Javawag

Posted 2011-02-20T15:18:49.603

Reputation: 179

Answers

3

You need to figure out what the actual problem is first... it sounds like your dynamic dns client isn't updating correctly after the connection is restored? You also do not state if the server is accessable by IP or another protocol and if it's only the web server part that's down? (voted to move to superuser)

Oskar Duveborn

Posted 2011-02-20T15:18:49.603

Reputation: 2 616

that could be the case actually! i didnt even think of that - ddclient runs as a daemon but i can run it in command line too as a one off thing... so i can try that next time it goes down.

the rest of the server is fine and accessible on 192.168.0.8 from within my network. even the web server part actually! – None – 2011-02-20T15:52:10.453

+1, might also be his client has the old IP cached... – Chris S – 2011-02-20T15:58:00.273

1

Hm well fixing things with reboot is not really a solution I think, nor is it needed here.

I'd say if your server can reach outside world, outside world can reach you too. You can put a cronjob to check if you can ping google every 5 min, and if not try to reset the network connection if you have some dialup PPP connection for DSL/cable or whatever.

Hrvoje Špoljar

Posted 2011-02-20T15:18:49.603

Reputation: 126

couldn't agree more, i'm just used to the "reboot and fix" approach when all else fails :P

that's a point! next time it goes down ill do a ping www.google.com and see what happens! – None – 2011-02-20T15:50:51.157

0

You could try using an external site like http://www.downforeveryoneorjustme.com and parse the output to see if your site is accessible or not. Be "polite" and don't check continuously...every 5 minutes should be fine.

You could also look into using an external monitoring service like Mon.Itor.Us but the problem here would be how to signal your site to restart if it is down or unavailable. If the issue is the server's network connection then you would want a solution that is entirely server side.

I would also try to figure out what the ultimate cause of the outages are. Since you appear to have a dynamic IP address I would see if it happens when that changes or even when DHCP updates happen on the server. If that is the cause then you can write a script to restart Apache when that happens.

uesp

Posted 2011-02-20T15:18:49.603

Reputation:

yeah, later when people aren't using it, i'll try taking the internet connection down on purpose and check some stuff on the server :) – None – 2011-02-20T15:50:30.720