zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
  templates:
    - uuid: 3cc8c9ae7055458c9a803597007f70bd
      template: 'Apache Tomcat by JMX'
      name: 'Apache Tomcat by JMX'
      description: |
        The template to monitor Apache Tomcat by Zabbix that work without any external scripts.
        The metrics are collected by JMX.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/411862-discussion-thread-for-official-zabbix-template-tomcat
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Applications
      items:
        - uuid: 7f6ec0e48d41456896799f487cd8243e
          name: Version
          type: JMX
          key: 'jmx["Catalina:type=Server",serverInfo]'
          value_type: CHAR
          username: '{$TOMCAT.USER}'
          password: '{$TOMCAT.PASSWORD}'
          description: 'The version of the Tomcat.'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 152d235652914aa2af78334385334214
              expression: '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'
              name: 'Version has been changed'
              event_name: 'Version has changed (new version: {ITEM.VALUE})'
              priority: INFO
              description: 'The Tomcat version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      discovery_rules:
        - uuid: a478be537e5f48fe95310997d0df0eda
          name: 'Protocol handlers discovery'
          type: JMX
          key: 'jmx.discovery[attributes,"Catalina:type=ProtocolHandler,port=*"]'
          delay: 1h
          username: '{$TOMCAT.USER}'
          password: '{$TOMCAT.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JMXATTR}'
                value: ^name$
          description: 'Discovery for ProtocolHandler'
          item_prototypes:
            - uuid: 830f58f8ad6640d989a70c01f7aa2ad8
              name: '{#JMXVALUE}: Gzip compression status'
              type: JMX
              key: 'jmx[{#JMXOBJ},compression]'
              value_type: CHAR
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Gzip compression status on {#JMXNAME}. Enabling gzip compression may save server bandwidth.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 1h
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: protocol-handler
                - tag: protocol-handler
                  value: '{#JMXVALUE}'
              trigger_prototypes:
                - uuid: 7d707de73a164f1db6b69e4dcb8c6ae9
                  expression: 'find(/Apache Tomcat by JMX/jmx[{#JMXOBJ},compression],,"like","off") = 1'
                  name: '{#JMXVALUE}: Gzip compression is disabled'
                  priority: INFO
                  description: 'gzip compression is disabled for connector {#JMXVALUE}.'
                  manual_close: 'YES'
                  tags:
                    - tag: scope
                      value: notice
          jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
        - uuid: 77175f79fe844bb8bca66de437a3ba32
          name: 'Global request processors discovery'
          type: JMX
          key: 'jmx.discovery[beans,"Catalina:type=GlobalRequestProcessor,name=*"]'
          delay: 1h
          username: '{$TOMCAT.USER}'
          password: '{$TOMCAT.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JMXNAME}'
                value: '{$TOMCAT.LLD.FILTER.REQUEST_PROCESSOR.MATCHES}'
              - macro: '{#JMXNAME}'
                value: '{$TOMCAT.LLD.FILTER.REQUEST_PROCESSOR.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for GlobalRequestProcessor'
          item_prototypes:
            - uuid: d7cb07f3f5e04792850332c416284dd9
              name: '{#JMXNAME}: Bytes received per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},bytesReceived]'
              units: B
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Bytes received rate by processor {#JMXNAME}'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: request
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: abad7332ed6b417c92f6038ce12ae000
              name: '{#JMXNAME}: Bytes sent per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},bytesSent]'
              units: B
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Bytes sent rate by processor {#JMXNAME}'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: request
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: 1596a335401d47d6b2bde7a5b0de7b07
              name: '{#JMXNAME}: Errors per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},errorCount]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Error rate of request processor {#JMXNAME}'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: request
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: 985d3eeacd9d404385bfcef693add39a
              name: '{#JMXNAME}: Requests processing time'
              type: JMX
              key: 'jmx[{#JMXOBJ},processingTime]'
              units: s
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: |
                The total time to process all incoming requests of request processor
                {#JMXNAME}
              preprocessing:
                - type: MULTIPLIER
                  parameters:
                    - '0.001'
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: request
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: 8e0307b5063549dab118e0e374a62aad
              name: '{#JMXNAME}: Requests per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},requestCount]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Rate of requests served by request processor {#JMXNAME}'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: request
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
          graph_prototypes:
            - uuid: 87de97d55baa4be1964652957a051fc2
              name: '{#JMXNAME}: Traffic'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},bytesSent]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},bytesReceived]'
          jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
        - uuid: cf1badf064714d9b9e3b7110696432f9
          name: 'Contexts discovery'
          type: JMX
          key: 'jmx.discovery[beans,"Catalina:type=Manager,host=*,context=*"]'
          delay: 1h
          username: '{$TOMCAT.USER}'
          password: '{$TOMCAT.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JMXHOST}'
                value: '{$TOMCAT.LLD.FILTER.MANAGER.MATCHES}'
              - macro: '{#JMXHOST}'
                value: '{$TOMCAT.LLD.FILTER.MANAGER.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for contexts'
          item_prototypes:
            - uuid: c20bb67db247471ba686d2ea371b7c73
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions active'
              type: JMX
              key: 'jmx[{#JMXOBJ},activeSessions]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Active sessions of the application.'
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: context
                - tag: jmx-context
                  value: '{#JMXCONTEXT}'
                - tag: jmx-host
                  value: '{#JMXHOST}'
            - uuid: bc3c2a3cff614f3eaf001463df1b2364
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions allowed maximum'
              type: JMX
              key: 'jmx[{#JMXOBJ},maxActiveSessions]'
              value_type: FLOAT
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'The maximum number of active Sessions allowed, or -1 for no limit.'
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: context
                - tag: jmx-context
                  value: '{#JMXCONTEXT}'
                - tag: jmx-host
                  value: '{#JMXHOST}'
            - uuid: fd8678e68cf440939af2dd8f3568a42f
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions active maximum so far'
              type: JMX
              key: 'jmx[{#JMXOBJ},maxActive]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Maximum number of active sessions so far.'
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: context
                - tag: jmx-context
                  value: '{#JMXCONTEXT}'
                - tag: jmx-host
                  value: '{#JMXHOST}'
            - uuid: 34702e2d6b2142ec9aa43bea1059a98a
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions rejected per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},rejectedSessions]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Rate of sessions we rejected due to maxActive being reached.'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: context
                - tag: jmx-context
                  value: '{#JMXCONTEXT}'
                - tag: jmx-host
                  value: '{#JMXHOST}'
            - uuid: eb28f9bd99d440f4a50d1c24ae758029
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions created per second'
              type: JMX
              key: 'jmx[{#JMXOBJ},sessionCounter]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Rate of sessions created by this application per second.'
              preprocessing:
                - type: CHANGE_PER_SECOND
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: context
                - tag: jmx-context
                  value: '{#JMXCONTEXT}'
                - tag: jmx-host
                  value: '{#JMXHOST}'
          graph_prototypes:
            - uuid: dfd46f5443f9438fb21ae23dfd4010c0
              name: '{#JMXHOST}{#JMXCONTEXT}: Sessions'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},maxActive]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},activeSessions]'
                - sortorder: '2'
                  drawtype: GRADIENT_LINE
                  color: 00611C
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},rejectedSessions]'
                - sortorder: '3'
                  drawtype: GRADIENT_LINE
                  color: F7941D
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},maxActiveSessions]'
          jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
        - uuid: 05752834671f416fb2fdac1006308c3e
          name: 'Thread pools discovery'
          type: JMX
          key: 'jmx.discovery[beans,"Catalina:type=ThreadPool,name=*"]'
          delay: 1h
          username: '{$TOMCAT.USER}'
          password: '{$TOMCAT.PASSWORD}'
          filter:
            evaltype: AND
            conditions:
              - macro: '{#JMXNAME}'
                value: '{$TOMCAT.LLD.FILTER.THREAD_POOL.MATCHES}'
              - macro: '{#JMXNAME}'
                value: '{$TOMCAT.LLD.FILTER.THREAD_POOL.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for ThreadPool'
          item_prototypes:
            - uuid: 7d7418c72ced48eca2a92e30021b611b
              name: '{#JMXNAME}: Threads count'
              type: JMX
              key: 'jmx[{#JMXOBJ},currentThreadCount]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Amount of threads the thread pool has right now, both busy and free.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 10m
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: thread-pool
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: 35b1e99fbc44448083b5aad0ce1239a1
              name: '{#JMXNAME}: Threads busy'
              type: JMX
              key: 'jmx[{#JMXOBJ},currentThreadsBusy]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Number of the requests that are being currently handled.'
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: thread-pool
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
            - uuid: 32e316ce567c4f94aecb89d9763e4d27
              name: '{#JMXNAME}: Threads limit'
              type: JMX
              key: 'jmx[{#JMXOBJ},maxThreads]'
              username: '{$TOMCAT.USER}'
              password: '{$TOMCAT.PASSWORD}'
              description: 'Limit of the threads count. When currentThreadsBusy counter reaches the maxThreads limit, no more requests could be handled, and the application chokes.'
              preprocessing:
                - type: DISCARD_UNCHANGED_HEARTBEAT
                  parameters:
                    - 10m
              jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
              tags:
                - tag: component
                  value: thread-pool
                - tag: jmx-name
                  value: '{#JMXNAME}'
                - tag: jmx-type
                  value: '{#JMXTYPE}'
          trigger_prototypes:
            - uuid: 7a15296553a447f6aebf4958631b6704
              expression: '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'
              name: '{#JMXNAME}: Busy worker threads count is high'
              event_name: '{#JMXNAME}: Busy worker threads count are more than {$TOMCAT.THREADS.MAX.PCT:"{#JMXNAME}"}% of the limit for {$TOMCAT.THREADS.MAX.TIME:"{#JMXNAME}"}'
              priority: HIGH
              description: 'When current threads busy counter reaches the limit, no more requests could be handled, and the application chokes.'
              tags:
                - tag: scope
                  value: notice
          graph_prototypes:
            - uuid: d8236335204a42488c6221c8b2d31e77
              name: '{#JMXNAME}: Worker threads'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},maxThreads]'
                - sortorder: '1'
                  drawtype: GRADIENT_LINE
                  color: F63100
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},currentThreadCount]'
                - sortorder: '2'
                  drawtype: GRADIENT_LINE
                  color: 00611C
                  item:
                    host: 'Apache Tomcat by JMX'
                    key: 'jmx[{#JMXOBJ},currentThreadsBusy]'
          jmx_endpoint: 'service:jmx:rmi:///jndi/rmi://{HOST.CONN}:{HOST.PORT}/jmxrmi'
      tags:
        - tag: class
          value: software
        - tag: target
          value: tomcat
      macros:
        - macro: '{$TOMCAT.LLD.FILTER.MANAGER.MATCHES}'
          value: '.*'
          description: 'Filter for discoverable managers.'
        - macro: '{$TOMCAT.LLD.FILTER.MANAGER.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude managers.'
        - macro: '{$TOMCAT.LLD.FILTER.REQUEST_PROCESSOR.MATCHES}'
          value: '.*'
          description: 'Filter for discoverable global request processors.'
        - macro: '{$TOMCAT.LLD.FILTER.REQUEST_PROCESSOR.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude global request processors.'
        - macro: '{$TOMCAT.LLD.FILTER.THREAD_POOL.MATCHES}'
          value: '.*'
          description: 'Filter for discoverable thread pools.'
        - macro: '{$TOMCAT.LLD.FILTER.THREAD_POOL.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude thread pools.'
        - macro: '{$TOMCAT.PASSWORD}'
          description: 'Password for JMX'
        - macro: '{$TOMCAT.THREADS.MAX.PCT}'
          value: '75'
          description: 'Threshold for busy worker threads trigger. Can be used with {#JMXNAME} as context.'
        - macro: '{$TOMCAT.THREADS.MAX.TIME}'
          value: 5m
          description: 'The time during which the number of busy threads can exceed the threshold. Can be used with {#JMXNAME} as context.'
        - macro: '{$TOMCAT.USER}'
          description: 'User for JMX'
      dashboards:
        - uuid: 330fa4902aed4d45b8747ddb2c8c7d70
          name: 'Tomcat: Overview'
          pages:
            - name: General
              widgets:
                - type: graphprototype
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Apache Tomcat by JMX'
                        name: '{#JMXHOST}{#JMXCONTEXT}: Sessions'
                    - type: STRING
                      name: reference
                      value: AAAAA
                    - type: INTEGER
                      name: rows
                      value: '3'
                - type: graphprototype
                  x: '36'
                  width: '36'
                  height: '15'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Apache Tomcat by JMX'
                        name: '{#JMXNAME}: Worker threads'
                    - type: STRING
                      name: reference
                      value: AAAAB
                    - type: INTEGER
                      name: rows
                      value: '3'
