homepage Welcome to WebmasterWorld Guest from 54.226.173.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Get email alert when apache goes down!
Is it possible and how?
smagdy




msg:3035481
 5:10 pm on Aug 5, 2006 (gmt 0)

Hello,

I have VDS and sometimes the server goes down for no reason!

So is there any program or something to use to send me email alert when it goes down, so i just turn it on again!

I am using Redhat Linux 9 and having installed

- Webmin
- usrmin
- Virtualmin Virtual Servers

Thanks in advance

 

chuckstarks




msg:3044039
 6:06 pm on Aug 12, 2006 (gmt 0)

I use shell monitors for all sorts of servers and for Apache have a special shell program that applies the httpd command (start, stop, graceful-stop) to an instance appropriately. I tested this script on a test bed and it appeared to work. You can put it, appropriately modified, in your own script and start it in the background from some S{name} program in the /etc/rc3.d or /etc/rc.d/rc3.d directory. Preferably the S{name} that starts your httpd service. These always run when your system boots. This shell program checks for the pid file, because a stop or graceful-stop removes the pid file. My other Apache service monitors put their own pid files in the same directory as the Apache pid file and my stop handling program stops these monitors as well.

DIR="YOUR HTTPD STARTUP DIRECTORY"
httpd -k $command -D $DIR -f $DIR/conf/httpd.conf
if [ "$command" = "start" ]
then
pidfile=`grep '^[ ]*PidFile[ ]*' $DIR/conf/httpd.conf ¦ awk '{ print $2 }'`
while [! -s $pidfile ]
do
sleep 1
done
pid=`cat $pidfile`
while true && [ -f $pidfile ]
do
if /bin/kill -0 $pid
then
sleep 5
continue
fi
if [ -f $pidfile ]
then
httpd -k stop -D $DIR -f $DIR/conf/httpd.conf
sleep 2
httpd -k start -D $DIR -f $DIR/conf/httpd.conf
while [! -s $pidfile ]
do
sleep 1
done
pid=`cat $pidfile`
fi
done
fi

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved