Many times I have seen people struggling to do monitoring set up on the Java based servers like Web logic , Web sphere or even commercial servers like Tibco etc. Any server which supports Java based application can be monitored with JMX Solutions. Even the commercial tools like Sitescope, Silk Performer Monitors use the Custom JMX Client classes behind the scenes to monitor the java based servers.
JMX provides the powerful API to monitor and manage any Java based application servers or infrastructure. Below are some benefits which I have seen we get by using the JMX API,
- Using the JMX we can monitor the health of all servers in the environment. Even if we have non Java based servers , we can always write the custom wrapper classes which can pull the performance stats from those servers. However this approach consumes some time, but is doable if we have skilled java resources. However if we have Java based infrastructure than probably other than enabling JMX , there is hardly any code is required.
- Configuring Resources on the server is also possible with JMX API. With JMX API we can monitor and configure the application and its services either fully or in part by exposing it to the JMX API.
- JMX also helps in debugging. Debugging can be enabled at runtime in case if required.
- JMX can also send out the alert notification, emails for critical events.However a listener needs to be Configured to send out the actual data.
Setting the JMX Based monitoring on the java based server involves the enabling the JMX Port in the start up option of the server. Normally it’s the flag which needs to be set up in java options of the server.
In this post I will show you as how to do set up in Apache Tomcat 7x server. I have installed the Apache Tomcat on my local machine as windows service.Once you have installed Tomcat as service, navigate to the bin directory of the server and right click tomcat7w.exe file. Please make sure that you run this with administrator rights.
In apache Tomcat 7 Properties windows, click on Java tab, you need to enter below options for local monitoring solutions.Please note that with below options we have turned off SSL and authentication is also switched off which means that you don’t need user id and password to connect to the server.
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
For remote monitoring of the server we need to enable remote port for jmx. Below options I have shown as how to set JMX Monitoring with user credentials, however if you don’t need user credentials, then probably, you can use options jmxremote.authenthicate as false.
-Dcom.sun.management.jmxremote.port=(your port number) -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file= path to password file
Below screenshot shows you the setting I have given in my tomcat server. Since JMX is based on JMX Specification, set up is pretty should be similar in other java based servers. However in those servers, we might set the java options in class path options while starting the servers.
Once the JMX options is enabled, we can use any JMX Client to connect to the server and gather the performance metrics. However please do note that application and server need to expose its functionality via Mbeans. Below screenshots shows the connection with JConsole,
Enabling the JMX Options is the first step you need to do if ever you want to monitor any java based servers with JMX.
Lot of people also say that enabling the JMX is cumbersome process, but my experience was bit different and after enabling it did not break any thing on my environment set up.