Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to launch java program from management application using JMX

Tags:

java

jmx

Assume I have a java program packaged in a executable jar which I normally start from the command line using java -jar myappjar.jar. Now I want to develop remote management application to launch this java program and also once launched I want to be able to stop it by which I mean it must call a method shutdown in my program which will do clean up work and exit the program.

Also when I launch the remote management application itself, it should tell me if the program I want to launch is already running, if so then stop it first.

Is all of above possible and how to achieve that ? Especially the most important is to be able to launch the program that is not running already.

The program that I launch is a server that keeps running forever until shutdown either manually or via remote management application. This server should in no way depend on JMX Agent or remote management application i.e. remote management application/JMX agent can be shutdown and server program still keeps running or server can be manually launched and later remote management application can be started to instrument this server program if so desired.

like image 485
ace Avatar asked Jun 17 '26 19:06

ace


1 Answers

What you actually need is a some kind of Management agent:

A Management agent is a software agent that runs on a managed node and provides an interface to manage it. It can perform operations on managed objects in the node and can also forward notifications to the manager.

Please see an example:

enter image description here

In your case it will be a JMX protocol between Management tool and applications. It is a precondition to have an Agent up and running on a remote host. It doesn't seem to be a hard task to develop a basic agent, capable of the following:

  • download/deploy an application
  • start/stop the application
  • monitor deployed application

Agent is a very simple application with several commands (management actions) implemented.

enter image description here

Useful link: Agents in Network Management

Update: glu agent example

glu is a free/open source deployment and monitoring automation platform. Glu is solving the following problems:

  • deploy (and monitor) applications to an arbitrary large set of nodes:
  • efficiently
  • with minimum/no human interaction
  • securely
  • in a reproducible manner

It is based on the same principle and has an agent in it:

The glu agent is an active process that needs to run on every host where applications need to be deployed. Its main role is to run glu scripts. It is the central piece of the deployment automation platform and is the only required piece of infrastructure. It exposes a REST api and a command line (which invokes the REST api under the cover).

Feel free to ask if you need some additional comments.

like image 67
Renat Gilmanov Avatar answered Jun 19 '26 08:06

Renat Gilmanov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!