I'm currently writing an app to monitor another Java process and take specific actions when certain targets are hit. For example, if a thread deadlocks for a certain time, kill the thread, if the memory usage goes over a specific amount, send email alerts and kill the process, etc.
My app will run as a stand-alone app, monitoring specific other apps (locally, though from what I can see remote or local makes no difference here).
I'm monitoring the external JVMs via MXBeans, but cannot see a clean way to kill the external process short of a system call like 'kill -9 ' (I'm working in UNIX by the way).
Is there any way to kill a JVM through the MXBean interfaces?
Graham
In your application implement a shutdown hook. When you want to shut down your JVM gracefully, install a Java Agent that calls System. exit() using the Attach API.
Benefits of JMX Technology Manages Java applications and services without heavy investment: JMX architecture relies on a core managed object server that acts as a management agent and can run on most Java-enabled devices. Java applications can be managed with little impact on their design.
JMX Monitoring to Improve the Performance of Java Applications. Easily monitor JVMs and Java web application servers with the eG Enterprise JMX monitoring solution. Improve the performance of your applications by identifying bottlenecks at the code-level and in the infrastructure.
The JMX technology can be used for out-of-the-box management of the Java VM. The Java Virtual Machine (Java VM) is highly instrumented using the JMX technology. You can start a JMX agent to access the built-in Java VM instrumentation, and thereby monitor and manage a Java VM remotely.
Sure. Implement an MBean on the target server that calls System.exit()
, and invoke that as a JMX operation from the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With