Tag Archives: monit

HOWTO monitor Tomcat with monit and munin in Debian

I have an existing Tomcat installation in production that has been running hot and causing monit to send me notices that such and such service is down, only to come back clear on the next run. Of course since I use monit I can see that the service was never restarted, plus I’ve never had this happen on other servers with monit, so I’m convinced that Tomcat, with its hunger for Java, is the culrprit here. I’ve been running munin for years on this server too, however I never got the Tomcat plugins to work with it, so I can’t gauge how hot Tomcat is running, and how changing the heap size is effecting things. Because of this, yesterday I got serious about it and finally got it working, but I had to take an end run to get it rolling and it wasn’t fun; which is why I’m posting it here. If anyone knows a better way to do this, please share in the comments and I’ll update this, but here’s how I was successful.

HOWTO use monit to monitor sites and alert users

Ok, I’ve used the process management software, monit, since at least 2004, and it is simply an indespensible tool in my sysadmin cache. Basically it watches a process, say like Apache, and restarts it if it dies. But wait, that’s not all, it does tons of other things. Want it to watch it and restart it at a certain time? Sure. How about if it uses 50% of system memory in 5 cycles (cycles are checks, 120 seconds by default)? Yep, it’ll take care of that. How about watching a file and stopping a service and/or issuing an alert by email or web if the file’s UID, permission, or whatever has changed?   No problem. Disk space is greater than 90% on one partition you want an email to go out to the admin? Easy. Seriously, once you start using monit you’ll be amazed at what you can cover, it’s truly one of the best tools I’ve ever used, and of course it’s GPL’d open source.

So, this week we had an issue where a some of our sites were down, and the monitor that watches them were internal to our network, and relied on some of the same resources; which is lees than ideal. I have a remote server running at one of our partner’s sites, so it’s the perfect canidate to watch our sites from a ‘real world’ view.