Monitoring Tomcat 5.0 on Ubuntu - Page 2
2 Setup Tomcat for Monitoring
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-n.n.n
2.1 Set Apache/JK Mount Point
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
2.2 Secure Your Installation
Keep in mind that depending on how you configured your Apache the whole world can access the hyperic webapp! Secure your setup by using the following example:
<Location> Order Deny,Allow Deny from all Allow from localhost #or Allow from iphyperichq </Location>
2.3 Enable Tomcat for Monitoring
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
In fact you can copy your files also to /usr/share/tomcat5/ which is a symbolic link to /usr/lib/tomcat5/.
<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.