Apache Tomcat 7 and above can be monitored. Both anonymous and authenticated JMX connections are supported.
Enabling JMX Remote
To enable JMX monitoring connections on Tomcat, please follow the relevant procedure depending on the operating system. TomcatHome refers to tomcat installation folder. The procedures below are inspired from Tomcat documentation explaining how to enable JMX remoting.
- Create a file named setenv.sh and put inside:
#!/bin/bash CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
Create a file named setenv.bat and put inside:
set CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9004 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
Enabling authentication is optional. Authentication protects your server JMX endpoint from being accessible to anyone. An alternative to authentication is to filter access to JMX port (9004 by default) using IPTables.
- Add the following JVM parameters to CATALINA_OPTS:
-Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access
- Edit the file $CATALINA_BASE/conf/jmxremote.access:
MonitorRole readonly controlRole readwrite
- Edit the file $CATALINA_BASE/conf/jmxremote.password:
MonitorRole tomcat controlRole tomcat
Apache Tomcat Configuration Wizard.
The Apache Tomcat monitor requires the following settings:
- Hostname: hostname or IP of the Apache Tomcat server. It must be reachable from the monitoring agent container,
- Port: JMX Remoting port, 9004 by default,
- Domain: Defines the Apache Tomcat MBeans domain. Catalina is by default,
- Authentication: Optionally define username and password.
To tailor a monitor counter list fitting the monitored system, the Apache Tomcat monitor asks to select the web applications to monitor.
Apache Tomcat Applications Selection.
In this configuration step, a table lists all the web applications deployed on the Tomcat server. select the deployed web applications to monitor then click on Next.
Apache Tomcat Counters Selection.
The Apache Tomcat monitoring module collects the following metrics:
- activeSessions: Number of currently active sessions,
- sessionCounter: Total number of created sessions,
- maxActive: Max number of active sessions,
- sessionMaxAliveTime: Max session alive time in ms,
- sessionAverageAliveTime: Average session alive time in ms,
- rejectedSessions: Number of rejected sessions,
- expiredSessions: Number of expired sessions,
- % rejectedSessions: Percent of rejected sessions.
- requestCount: Number of requests received,
- errorCount: Number of errors encountered,
- bytesSent: Number of bytes sent,
- maxTime: Maximum processing time since server startup in ms,
- processingTime: Current processing time in ms,
- % errorCount: Percent of errors encountered (errorCount / requestCount).
- numActive: Number of active JDBC connections,
- numTestsPerEvictionRun: determines the number of objects examined in each run of the idle object evictor,
- numIdle: Number of idle JDBC connections,
- maxActive: Maximum number of active JDBC connections since server startup,
- % numActive: Percent of active JDBC connections,
- maxIdle: Maximum of idle JDBC connections since server startup,
- poolConfiguration: Textual JDBC connections pool configuration.
- currentThreadsBusy: Current number of threads being busy,
- currentThreadCount: Current number of threads being alive,
- maxThreads: Maximum number of threads the pool can spawn,
- threadsConfiguration: Textual thread pool configuration.
- used: memory used by the JVM in bytes,
- commited: memory commited by the JVM in bytes,
- max: max JVM memory in bytes,
- % used: Percent used memory (used / max).
- CollectionCount: Number of garbage collections,
- CollectionTime: Time spend in garbage collection.
- ThreadCount: Number of threads currently running in the JVM,
- DaemonThreadCount: Number of daemon threads currently running in the JVM,
- PeakThreadCount: Maximum number of threads running since JVM startup.
- Host: operating system host configuration (CPU, RAM and Swap),
- JVM: Textual Java Virtual Machine name and version.
The available counters may vary depending on the Tomcat version being monitored.