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
Probleme mit Ubuntu 7.04 Kernel Update
Der aktualisierte Ubuntu-Kernel 2.6.20-16 verwendet wohl nicht mehr das Schema des Vorgängers 2.6.20-15 nachdem auch die IDE-Platten als sd(x) benannt werden. Nach dem Kernel-Update heute morgen startet das System mit den neuen Kernel nicht. In der /etc/fstab verwende ich die tatsächlichen Gerätenamen und nicht die UUIDs. Der neue Kernel möchte dort wieder hd(x) sehen.
Eine Diskussion zu dem Thema findet sich in den Ubuntu Forums.
UPDATE: Der entsprechende Bugeintrag bei launchpad
VMWare Player 2.0
ist draussen und weder heise noch golem berichten ?!
note to myself
- Per mod-jk gemountete Tomcat-Applikationen werden im Apache mittels der
Location-Direktive konfiguriert.
Feisty Fawn: Upgrade auf ATA-Systemen
Führt man ein Upgrade von Ubuntu auf Feisty Fawn 7.04 auf ATA-Platten durch, kommt es zu Problemen nach dem Neustart.
Feisty Fawn verwendet den Kernel 2.6.20-15 oder höher mit einem neuen Treiber für die ATA und ATAPI-Geräte. Eine wichtige Eigenschaft dieses Treiber ist, das ATA-Geräte jetzt wie SCSI und Serial-ATA Geräte als /dev/sd* im System erscheinen. Beim Upgrade wird die /etc/fstab leider nicht entsprechend angepasst und man sollte die Einträge vor dem Neustart per Hand ändern (z.B. von /dev/hda1 in /dev/sda1).
Hat man das versäumt muss man mit einem alten Kernel booten und danach die entsprechend /etc/fstab anpassen.
Update: Die persistenten UUIDs haben sich nach dem Upgrade von 6.10 auf 7.04 nicht verändert. Der neue Kernel konnte die Partitionen jedoch nicht mounten.
pcnet32 vs vmxnet: VMWare Appliance Ubuntu Server
VMWare Appliances sind teilweise vorkonfigurierte oder komplett konfigurierte virtuelle Maschinen für verschiedene Zwecke. Ubuntu Server gibts auch als Appliance zum Download. Bei der Version 6.10 hatte ich immer Probleme mit den Netzwerkinterfaces. Es wird bei dieser Appliance als Netzwerktreiber das Modulpcnet32 anstatt der moderne vmxnet geladen. Zusammen mit der Konfiguration der vmware-tool führte bei mir dazu das gar kein Netzwerkinterface verfügbar war.
Trägt man in die Datei /etc/modprobe.d/blacklist die Zeile blacklist pcnet32 ein und befolgt man die Anweisungen nach der Installation/Konfiguration der vmware-config-tools.pl wird nach einem Neustart der moderne Treiber geladen.
Feisty Fawn: Upgrade geglückt
Das Upgrade von Ubuntu 6.10 auf 7.04 war absolut unkompliziert. Es gab lediglich zwei Probleme:
Die Fensterrahmen beim 3D-Windomanager Beryl wurden nicht dargestellt. Eine Lösung findet sich hier.
Die VMWare-Installation bricht beim Kompilieren der Kernel-Module ab. Wie man dieses Problem löst kann man an dieser Stelle nachlesen.
Ansonsten läuft alles wie geschmiert
Merken: Java Security Manager
Installiert man Tomcat5 in Ubuntu 6.06 LTS per apt-get aus den Ubuntu-Repositories ist der Java Security Manager standardmäßig aktiviert. Wenn man den nicht konfiguriert oder abschaltet weigert sich Tomcat u.a. eine Verbindung zu einer Datenbank aufzubauen.
Die Fehlermeldung sieht ungefähr so aus:
E SqlWrap: Exception Cannot create PoolableConnectionFactory (Server connection failure during transaction. Due to underlying exception: 'java.security.AccessControlException: access denied (java.net.SocketPermission localhost resolve)'.
** BEGIN NESTED EXCEPTION **
java.security.AccessControlException
MESSAGE: access denied (java.net.SocketPermission localhost resolve)
Deaktivieren kann man ihn im Start/Stop-Skript /etc/init.d/tomcat :
# Use the Java security manager? (yes/no)
TOMCAT5_SECURITY=no
Um das herauszufinden hab ich drei Stunden gebraucht.Grrr…
Comments (4)
Leave a Comment
Comments (1)
![Pier 3 [DSC_0466.JPG] Pier 3 [DSC_0466.JPG]](http://farm3.static.flickr.com/2789/4202214037_7859f5da38_t.jpg)
![[DSC_0434.JPG] [DSC_0434.JPG]](http://farm3.static.flickr.com/2723/4202211601_a02ab5411c_t.jpg)
![Muriwai Beach [DSC_0123.AVI] Muriwai Beach [DSC_0123.AVI]](http://farm3.static.flickr.com/2586/4191702733_13e2a44dee_t.jpg)
