Hyperic: Configure Tomcat 5.0 for Monitoring in Ubuntu

Update: Setting up Tomcat Monitoring for Ubuntu is exactly how it’s decribed in the official documentation. I was a little bit confused by the symbolic links in the filesystem and thought myself to be wiser than the Hypericans :-( Sorry about that. There ist one little difference is in the configuration of the Apache-Tomcat connector. But maybe its worth reading because I wrote something about howto protect the webapp if you’re using Apache.

Setting up Tomcat Monitoring in Hyperic is easy by reading the documentation.
If you’re going to do that in Debian-based Distributions it’s a little bit different to the original documentation. I set up tomcat monitoring on Nexenta GNU/OpenSolaris and Ubunbtu 6.06 LTS Here it ist:

At first download an install an Hyperic Agent on your Tomcat-Machine. For Ubuntu use hyperic-hq-agent-n.n.n-nnn-x86-linux.tgz oder for 64-Bit AMD Systems hyperic-hq-agent-n.n.n-nnn-amd64-linux.tgz.
My Nexenta installation is in Virtual Machine on a x86-System, so I got hyperic-hq-agent-3.0.4-389-noJRE.tgz and installed a Java Runtime Environement for myself.

To enable monitoring of Tomcat servers and services the Tomcat server must be instrumented using a filter to collect metrics and a webapp to deliver the metric data into HQ. The web application, filter and any additional jars are packaged in the HQ agent directory under product_connectors/servlet-3.0.4 for HQ Agent 3.0.4. All commands below should be issued from this directory.

If you are using Apache/JK to front your Tomcat installation you will need to setup a mount point. This can be done by adding the following to your Apache configuration /etc/apache2/conf.d/jk file.
You can find an example in /usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf

JkMount /hyperic-hq/* ajp13_worker

Keep in mind that depending on how you configured your Apache the whole world can access the hyperic webapp ! I would advise you to use secure it by set up up the following Apache directive:
<Location>
Order Deny,Allow
Deny from all
Allow from localhost
#or
Allow from iphyperichq
</Location>

The first step to making Tomcat monitorable is to install the filter, JMX jars and webapp. These are used to collect internal Tomcat metrics.

cp libs/hq-filter.jar /usr/lib/tomcat5/common/lib
cp libs/mx4j-jmx.jar /usr/lib/tomcat5/common/lib
cp -R hyperic-hq /usr/lib/tomcat5/webapps

In fact you can copy your files also to /usr/share/tomcat5/ which is a symbolic link to /usr/lib/tomcat5/.

Finally, the filter must be enabled. The following must be added to /etc/tomcat5/web.xml. Keep in mind that each tag type must be grouped together.

<filter>
<filter-name>JMXFilter</filter-name>
<filter-class>org.hyperic.hq.product.servlet.filter.JMXFilter</filter-class>

<!– Uncomment the following line to enable response time logging.
The directory you specify as the param can include properties
referenced from the System.properties of the vm.

The ResponseTime log file will by default store the last 1 hour’s
worth of response time data. This file gets truncated as soon as
data is succesfully sent into the server. The file is named uniquely
for each webapp in the form: yourContextName_HQResponseTime.log

If this fragment is included in the global web.xml for the container,
all webapps in it will generate response time data, and have logs
following the format described above. You can enable it individually
on each webapp as well if you dont want every webapp to generate
response time data

–>
<!–
<init-param>
<param-name>responseTimeLogDir</param-name>
<param-value>/var/lib/tomcat5/logs</param-value>
</init-param>
–>

<!– these are optional parameters which you can override to optimize logging –>
<!–
<init-param>
<param-name>bufferSize</param-name>
<param-value>8k</param-value>
</init-param>

<init-param>
<param-name>bufferTime</param-name>
<param-value>1h</param-value>
</init-param>
–>
</filter>

<filter-mapping>
<filter-name>JMXFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<listener>
<listener-class>org.hyperic.hq.product.servlet.filter.JMXSessionListener</listener-class>
</listener>

<servlet>
<servlet-name>JMXWebappMetricServlet</servlet-name>
<servlet-class>org.hyperic.hq.product.servlet.filter.JMXFilterInitServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

This can be tested by verifying your webapps show up correctly in the JMX Servlet. You may need to modify the hostname in the URL if your jmxUrl is configured relative to the agent host or if you use Apache in front of your Tomcat-Installation as described above.

Configure Tomcat 5.0 for Log Tracking

To enable Log Tracking in HQ, Tomcat must be configured with log4j. These steps are based on the standard Tomcat documentation.

On a blank Ubuntu-Installation /usr/lib/tomcat5/common/classes/log4j.properties does not exist, so create one with the following example contents:

#These properties can be modified. The only requirement is that the
#ConversionPattern includes the priority (%p)
log4j.rootLogger=INFO, R
log4j.appender.R.File=${catalina.home}/logs/tomcat.log
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.MaxFileSize=5000KB
log4j.appender.R.layout.ConversionPattern=%d %-5p [%c{1}] %m%n
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R=org.apache.log4j.RollingFileAppender

Next, copy the following jars unless they have already been installed:

cp pdk/lib/log4j.jar /usr/lib/tomcat5/common/lib
cp pdk/lib/commons-logging.jar /usr/lib/tomcat5/common/lib

Restart Tomcat for the changes to take effect: /etc/init.d/tomcat5 restart

About these ads

4 comments so far

  1. [...] love it when a community comes together! This morning I came across this blog post all about how easy it is to set up Tomcat monitoring on Ubuntu with HQ. As a bonus, the same [...]

  2. Tomcat 6 Monitoring « Dünnes on

    [...] Posted Oktober 3, 2007 Ich habe ja bereits an anderer Stelle beschrieben wie man Tomcat 5.x  überwachen kann. Mit der Tomcat Version 6.0 wird die ganze Sache noch einfacher und eleganter, da Tomcat 6 die [...]

  3. OpenSolaris Indiana « Dünnes on

    [...] 2007 Neugierig durch den Artikel auf heise.de über OpenSolaris und durch meine Experimente mit Nexenta habe ich mir OpenSolaris Indiana als VM in VMWare Server installiert. Das es nicht ganz problemlos [...]

  4. Jason Meiers on

    As an independent contractor from http://www.camsolutionsinc.com I recently evaluated a potencial purchase for one of the largest online retailers, the monitoring tools Hyperic. I found it too that has a very cool looking interface ( ajax ) and auto-discovery feature ( command line scrapper) . Plattforms supported are Linux, Solaris and Mac OS, Windows XP.

    Looking at an IT department with a few boxes your can quickly deploy the auto discovery agents and identify your mysql database and apache server no problem. I really look forward to the vision to where the open source products Nagios and Hyperic are going in terms of event management.

    For application monitoring, transaction monitoring and enterprise event monitoring this product is not really helpful. There are a few application deep-dive diagnostics tools from other vendors that I’ve seen through my evaluation that fit deep dive monitoring requirements for java applications.

    Gruss


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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: