After running out of memory with a Java application, I wanted to monitor the internal Java memory usage.
It cost me quite some time trying to get the information I seeked from JMX, still have not figured that out. Suddenly I ran into a simple Nagios-plugin that utilizes the jstat-command to just get the heap- and permgen usage from a java-process. The original plugin can be found here: https://github.com/Ericbla/check_jstat.
I have converted the plugin for use in Check_MK, see my version here: cmk_jstat.sh
Just place this one in /usr/lib/check_mk/local and create a configuration file /etc/check_mk/jstat.conf with the name of the service you'd like to check and the pidfile. So, if you'd like to monitor Tomcat, you could place something like this in the configuration file: