Web Hosting Talk







View Full Version : [Urgent] Shell script check http content


FrzzMan
07-13-2004, 05:30 AM
Hello,

My Apache seem to have some hiccups these days... by random interval, it just hang... request never be served. I have to restart it so it will work again...

Recompiled Apache but it still behave like this... it so inconvenient to manual restart everytime it hang...

Until the problem is solve, please help me a script that check http content, the script will run by cron job every 5', request an http page on the server, timeout in 10", if the content is not match. Then the script will issue a restart command.

TIA.

BigBison
07-13-2004, 06:16 AM
I hope you'll get other replies, but Alertra (http://www.alertra.com) scripting does this, from an external site to yours and send you an email or SMS alert. There are other companies that do the monitoring you describe, in addition to alertra. I also think you'll run into trouble running as cron job on the same system as the Apache installation. I thought of a couple reasons, but went with brevity here. The reason I say alertra is their scripting doesn't just ping the server, it checks to see if your pages render, this may help you identify your 'hiccups'.

FrzzMan
07-13-2004, 09:27 AM
Thanks, but I think it won't help much since it can't do nothing except notice me about the failure, I still have to restart Apache myself...

Thanks anyway...

Mdot
07-13-2004, 10:27 AM
try something simple like

#!/bin/sh

GET http://localhost 2>&1 >/dev/null || /usr/local/apache/bin/apachectl restart


if "GET" fails, next command will restart apache.

regards,
M.

BigBison
07-13-2004, 10:30 AM
Originally posted by FrzzMan
Thanks, but I think it won't help much since it can't do nothing except notice me about the failure...

Not really -- here's why. You haven't provided any information as to whether you're running a database, etc. which makes this tougher to answer for everyone who reads your post. If you're making a SQL call and that's what makes the server unresponsive, having an external script not only notifies you but will also generate server logs useful in the troubleshooting process, as opposed to blind troubleshooting of what sounds like a toughie. :)

Meantime, I hope Miha's solution works for you, but I think your focus should be figuring out what the problem is, not automating your restarts.

FrzzMan
07-13-2004, 01:24 PM
Yeah thanks, as I said in the 1st post "until the problem is solve", this is temporary solution, cuz I can't stay at the server monitoring screen to restart apache when it gone wild...

Uhm, Miha, can you describe a lil about your script??? I don't know what the "2>&1" mean??? I used it, but it's a lil curious :D

Mdot
07-13-2004, 04:15 PM
Originally posted by FrzzMan

Uhm, Miha, can you describe a lil about your script??? I don't know what the "2>&1" mean??? I used it, but it's a lil curious :D

it basically redirects all errors/messages from "GET" command to >/dev/null

regards,
M.