HowTo: Setup javameloy for watching J2EE application server activities

Posted on Updated on

Javamelody is a tool to monitor J2EE application servers, I has capability for showing real-time statistics,  I have integrated this tool with nearly 40 servers which connected with Javamelody collector server . It is the good choice for debugging and fine tunning J2EE applications by statistics history. Once you connected the java melody to an collector server it role it to collect all the data from the connected server for every 1 min. it will be avoid storing GBs of statistics data in the application server.

For more details Please check this https://code.google.com/p/javamelody/wiki/UserGuide#Introduction

I followed the given steps for deploying in Tomcat containers,

Packages:

https://javamelody.googlecode.com/files/javamelody-1.49.0.jar
https://pastockscanner.googlecode.com/files/iText-2.1.7.jar
http://sourceforge.net/projects/jrobin/files/jrobin/1.5.9/jrobin-1.5.9.1.jar/download

Installation,

1, Copy the jars to the lib dir of the applications

cp -rpf javamelody-1.49.0.jar iText-2.1.7.jar jrobin-1.5.9.1.jar <webapps>/ROOT/WEB-INF/lib

2, Modify  web.xml

cp -rpf web.xml web.xml_$(date +%F)
vi <webapps>/ROOT/WEB-INF/web.xml
<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>
 /WEB-INF/application-context.xml
 classpath:net/bull/javamelody/monitoring-spring-datasource.xml
 </param-value>
 </context-param>
 <!--====================== Monitoring ===================================-->
 <!-- Custom CSS -->
 <filter>
 <filter-name>customResourceFilter</filter-name>
 <filter-class>net.bull.javamelody.CustomResourceFilter</filter-class>
 </filter>
 <filter-mapping>
 <filter-name>customResourceFilter</filter-name>
 <url-pattern>/monitoring</url-pattern>
 </filter-mapping>
 <!-- Monitor filter -->
 <filter>
 <filter-name>monitoring</filter-name>
 <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
 <init-param>
 <param-name>storage-directory</param-name>
 <param-value>logs/monitoring</param-value>
 </init-param>
 <init-param>
 <param-name>url-exclude-pattern</param-name>
 <param-value>(/images/.*|/js/.*|/styles/.*)</param-value>
 </init-param>
 <init-param>
 <param-name>admin-emails</param-name>
 <param-value>first.last@example.com</param-value>
 </init-param>
 <init-param>
 <param-name>mail-session</param-name>
 <param-value>MailSession</param-value>
 </init-param>
 <init-param>
 <param-name>mail-periods</param-name>
 <param-value>week,month</param-value>
 </init-param>
 </filter>
 <filter-mapping>
 <filter-name>monitoring</filter-name>
 <url-pattern>/*</url-pattern>
 </filter-mapping>
 <listener>
 <listener-class>net.bull.javamelody.SessionListener</listener-class>
 </listener>
<security-constraint>
 <web-resource-collection>
 <web-resource-name> monitoring URL </web-resource-name>
 <url-pattern> /monitoring/* </url-pattern>
 <http-method> GET </http-method>
 <http-method> POST </http-method>
 </web-resource-collection>
<auth-constraint>
 <!-- the same like in your tomcat-users.conf file -->
 <role-name> watcher </role-name>
 </auth-constraint>
 </security-constraint>
<login-config>
 <auth-method> BASIC </auth-method>
 <realm-name> Password please !!! </realm-name>
 </login-config>
<security-role>
 <description> </description>
 <role-name> watcher </role-name>
 </security-role>

2, Modify security.xml if needed

cp -rpf security.xml security.xml_$(date +%F)
vi  <webapps>/ROOT/WEB-INF/security.xml
<sec:http pattern="/monitoring/**" security="none"></sec:http>

3, Add the credential for basic auth

cp -rpf tomcat-users.xml tomcat-users.xml_$(date +%F)
vi $CATALIAN_HOME/conf/tomcat-users.xml
<user username="user" password="password" roles=watcher"/>

Now restart the tomcat.

URL : http://my-applicationserver.com/monitoring

This is only for those who deployed more than one Javamelody.

JavaMelody collector server installation:

Download and Deploy the collector application in the webserver

https://javamelody.googlecode.com/files/javamelody-1.49.0.war

From the browser you can see the application like below

Monitoring JavaMelody on Beijing stg2 web3 BeijingInternal

 

Name of application to monitor : Just a name to identify the application it can be any thing

eg : mywebserver1 , mywebserver2

URL(s): Valid monitoring URL without “/monitoring”, provide basic authentication if enabled.

eg : http://<username&gt;:<password>@mywebserver1.com

It can be add many javamelody instances like below:

Server

 

Advertisements

2 thoughts on “HowTo: Setup javameloy for watching J2EE application server activities

    dan said:
    September 5, 2015 at 12:08 am

    Hello! Thanks for this post. Have you had any experience using Spring Security with the collect server?

      Anand babu responded:
      September 5, 2015 at 1:13 am

      Yes, I worked on collect server and spring security.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s