# Apache Tomcat by JMX ## Overview This template is designed for the effortless deployment of Apache Tomcat monitoring by Zabbix via JMX and doesn't require any external scripts. ## Requirements Zabbix version: 7.0 and higher. ## Tested versions This template has been tested on: - Apache Tomcat 8.5.59 ## Configuration > Zabbix should be configured according to the instructions in the [Templates out of the box](https://www.zabbix.com/documentation/7.0/manual/config/templates_out_of_the_box) section. ## Setup Metrics are collected by JMX. 1. Enable and configure JMX access to Apache Tomcat. See documentation for [instructions](https://tomcat.apache.org/tomcat-10.0-doc/monitoring.html#Enabling_JMX_Remote) (chose your version). 2. If your Tomcat installation require authentication for JMX, set values in host macros {$TOMCAT.USERNAME} and {$TOMCAT.PASSWORD}. 3. You can set custom macro values and add macros with context for specific metrics following macro description. ### Macros used |Name|Description|Default| |----|-----------|-------| |{$TOMCAT.USER}|
User for JMX
|| |{$TOMCAT.PASSWORD}|Password for JMX
|| |{$TOMCAT.LLD.FILTER.MATCHES}|Filter for discoverable objects. Can be used with following contexts: "GlobalRequestProcessor", "ThreadPool", "Manager"
|`.*`| |{$TOMCAT.LLD.FILTER.NOT_MATCHES}|Filter to exclude discovered objects. Can be used with following contexts: "GlobalRequestProcessor", "ThreadPool", "Manager"
|`CHANGE IF NEEDED`| |{$TOMCAT.THREADS.MAX.PCT}|Threshold for busy worker threads trigger. Can be used with {#JMXNAME} as context.
|`75`| |{$TOMCAT.THREADS.MAX.TIME}|The time during which the number of busy threads can exceed the threshold. Can be used with {#JMXNAME} as context.
|`5m`| ### Items |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Tomcat: Version|The version of the Tomcat.
|JMX agent|jmx["Catalina:type=Server",serverInfo]**Preprocessing**
Discard unchanged with heartbeat: `1d`
The Tomcat version has changed. Acknowledge to close the problem manually.
|`last(/Apache Tomcat by JMX/jmx["Catalina:type=Server",serverInfo],#1)<>last(/Apache Tomcat by JMX/jmx["Catalina:type=Server",serverInfo],#2) and length(last(/Apache Tomcat by JMX/jmx["Catalina:type=Server",serverInfo]))>0`|Info|**Manual close**: Yes| ### LLD rule Global request processors discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Global request processors discovery|Discovery for GlobalRequestProcessor
|JMX agent|jmx.discovery[beans,"Catalina:type=GlobalRequestProcessor,name=*"]| ### Item prototypes for Global request processors discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |{#JMXNAME}: Bytes received per second|Bytes received rate by processor {#JMXNAME}
|JMX agent|jmx[{#JMXOBJ},bytesReceived]**Preprocessing**
Bytes sent rate by processor {#JMXNAME}
|JMX agent|jmx[{#JMXOBJ},bytesSent]**Preprocessing**
Error rate of request processor {#JMXNAME}
|JMX agent|jmx[{#JMXOBJ},errorCount]**Preprocessing**
Rate of requests served by request processor {#JMXNAME}
|JMX agent|jmx[{#JMXOBJ},requestCount]**Preprocessing**
The total time to process all incoming requests of request processor
{#JMXNAME}
|JMX agent|jmx[{#JMXOBJ},processingTime]**Preprocessing**
Custom multiplier: `0.001`
Discovery for ProtocolHandler
|JMX agent|jmx.discovery[attributes,"Catalina:type=ProtocolHandler,port=*"]| ### Item prototypes for Protocol handlers discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |{#JMXVALUE}: Gzip compression status|Gzip compression status on {#JMXNAME}. Enabling gzip compression may save server bandwidth.
|JMX agent|jmx[{#JMXOBJ},compression]**Preprocessing**
Discard unchanged with heartbeat: `1h`
gzip compression is disabled for connector {#JMXVALUE}.
|`find(/Apache Tomcat by JMX/jmx[{#JMXOBJ},compression],,"like","off") = 1`|Info|**Manual close**: Yes| ### LLD rule Thread pools discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Thread pools discovery|Discovery for ThreadPool
|JMX agent|jmx.discovery[beans,"Catalina:type=ThreadPool,name=*"]| ### Item prototypes for Thread pools discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |{#JMXNAME}: Threads count|Amount of threads the thread pool has right now, both busy and free.
|JMX agent|jmx[{#JMXOBJ},currentThreadCount]**Preprocessing**
Discard unchanged with heartbeat: `10m`
Limit of the threads count. When currentThreadsBusy counter reaches the maxThreads limit, no more requests could be handled, and the application chokes.
|JMX agent|jmx[{#JMXOBJ},maxThreads]**Preprocessing**
Discard unchanged with heartbeat: `10m`
Number of the requests that are being currently handled.
|JMX agent|jmx[{#JMXOBJ},currentThreadsBusy]| ### Trigger prototypes for Thread pools discovery |Name|Description|Expression|Severity|Dependencies and additional info| |----|-----------|----------|--------|--------------------------------| |{#JMXNAME}: Busy worker threads count is high|When current threads busy counter reaches the limit, no more requests could be handled, and the application chokes.
|`min(/Apache Tomcat by JMX/jmx[{#JMXOBJ},currentThreadsBusy],{$TOMCAT.THREADS.MAX.TIME:"{#JMXNAME}"})>last(/Apache Tomcat by JMX/jmx[{#JMXOBJ},maxThreads])*{$TOMCAT.THREADS.MAX.PCT:"{#JMXNAME}"}/100`|High|| ### LLD rule Contexts discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |Contexts discovery|Discovery for contexts
|JMX agent|jmx.discovery[beans,"Catalina:type=Manager,host=*,context=*"]| ### Item prototypes for Contexts discovery |Name|Description|Type|Key and additional info| |----|-----------|----|-----------------------| |{#JMXHOST}{#JMXCONTEXT}: Sessions active|Active sessions of the application.
|JMX agent|jmx[{#JMXOBJ},activeSessions]| |{#JMXHOST}{#JMXCONTEXT}: Sessions active maximum so far|Maximum number of active sessions so far.
|JMX agent|jmx[{#JMXOBJ},maxActive]| |{#JMXHOST}{#JMXCONTEXT}: Sessions created per second|Rate of sessions created by this application per second.
|JMX agent|jmx[{#JMXOBJ},sessionCounter]**Preprocessing**
Rate of sessions we rejected due to maxActive being reached.
|JMX agent|jmx[{#JMXOBJ},rejectedSessions]**Preprocessing**
The maximum number of active Sessions allowed, or -1 for no limit.
|JMX agent|jmx[{#JMXOBJ},maxActiveSessions]| ## Feedback Please report any issues with the template at [`https://support.zabbix.com`](https://support.zabbix.com) You can also provide feedback, discuss the template, or ask for help at [`ZABBIX forums`](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback)