Google
 
Web QrooniX

Saturday, August 18, 2007

Monit and Tomcat

Tomcat is acting up. We need to see if it died gracefully or hanged. Using monit we can monitor tomcat's pid. But what if it is hanging in there? So, using some monit option, we could check the tomcat's http response at port 8080.

## Monitor Tomcat's pid
check process tomcat with pidfile /opt/tomcat/logs/tomcat.pid
alert some.alerts@some.domain
mode passive
#
## Monitor Tomcat at port 8080
check host localhost with address 127.0.0.1
start program = "/etc/init.d/tomcat start"
stop program = "
/etc/init.d/tomcat stop"
if failed port 8080 protocol http
then restart
alert
some.alerts@some.domain

Reset monit services, stop the tomcat services and check the logs.

tail -f /var/log/monit.log

ps -ef | grep tomcat

Hhhmmm... something's weird. Monit didn't restart Tomcat. Check the logs and got these:

info : 'tomcat' start: /etc/init.d/tomcat
error : 'tomcat' failed to start

Googled some. I then put the /etc/init.d/tomcat start/stop on a simple script.

touch start-tomcat.sh
touch stop-tomcat.sh

And changed the /etc/init.d/ lines at monit.conf to:

start program = "/somedir/start-tomcat.sh"
start program = "/somedir/stop-tomcat.sh"

Test the configs and voila! Back to playing some basic bass stuff: 12 bar blues progression.

Labels: , ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?