I want to create a nagios watchdog for JVM that looks when the JVM runs out of memory and restarts it.
Currently I was able to setup the JVM be allow JMX but I don't know how to detect OutOfMemory condition and restart it.
/check_jmx -U service:jmx:rmi:///jndi/rmi://127.0.0.1:1100/jmxrmi -O "java.lang:type=Memory" -A "HeapMemoryUsage" -K used -I HeapMemoryUsage -J used -vvvv
JMX OK HeapMemoryUsage.used=957414288{committed=2415984640;init=2147483648;max=2863333376;used=957414288}