Hi and Happy Holidays! I have a server currently running Apache Tomcat. It often crashes when the connections go over 40. The previous admin created a script that restarts apache and tomcat when it hits 40 connections. I was wondering if it's possible to to the same thing with Monit. Here is the current cron script that runs every minute: Code: #!/bin/bash source /etc/profile RESDATE=`date "+DATE: %m/%d/%y TIME: %H:%M:%S"` USER=`netstat -tunlap | grep ESTABLISHED | grep -v sshd | grep -v '127.0.0.1' | wc -l` if [ "$USER" -gt 40 ] || [ "$USER" = 0 ] then echo " SERVER RESTART @ $RESDATE" >> /root/scripts/RESTARTS.TXT service httpd stop;/usr/local/tomcat/bin/shutdown.sh;sleep 5;/usr/local/tomcat/bin/startup.sh;service httpd start else cat /dev/null fi Is there a way to get Monit to do the same thing with the above script? Thanks!
There might be another way to use monit: if Apache Tomcat logs its crashes, you can make monit look at the log, and when it finds a line indicating that Apache Tomcat has crashed, it can restart Apache Tomcat. http://www.tildeslash.com/monit/doc/manual.php#file_content_testing
Thanks for the reply. We've adjusted some things on the java app side that keeps apache tomcat from crashing. We have noticed that now when connection go over 40, the server goes to a crawl. I'm thinking that the connections aren't flushing or not being released. We don't need to recode the application because we are dropping tomcat in a few months and moving to ruby and rails. So for the time being, I just need monit to restart apache tomcat whenever it hits 40 connections. The script above lets us track how many times the servers are being restarted. Manually logging it doesn't make sense. I would rather have a system like monit and munin/cacti. It's just pretty slim on finding things on managing apache tomcat with monit.