Apache Tomcat, often referred to as Tomcat Server, is an open-source Java Servlet Container developed by the Apache Software Foundation (ASF). Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a “pure Java” HTTP web server environment in which Java code can run.

Tomcat is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation, released under the Apache License 2.0 license, and is open-source software.

Prerequisites

  1. For standard installation of Tomcat (extracting the tar), add the following in the ~/.bashrc file:
export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64  #add this line where jvm is installed on the machine
export export CATALINA_HOME=/opt/tomcat/apache-tomcat-7.0.105  #add this line where the extracted directory is present
  1. Create a file setenv.sh, add the following lines, and execute the file before you start the Tomcat server:
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=7199 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
  1. For Virtual Machines, install the Linux Agent.

Configuring the credentials

Configure the credentials in the directory /opt/opsramp/agent/conf/app.d/creds.yaml

tomcat:
- name: tomcat
  user: <username>
  pwd: <Password>
  encoding-type: plain
  labels:
    key1: val1
    key2: val2

Configuring the application

Virtual machine

Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-detection.yaml

- name: tomcat
  instance-checks:
    process-check:
      - tomcat
    port-check:
      - 8080
  mon-type: "jmx"
  misc:
    jmx-port: "7199"

Docker environment

Configure the application in the directory /opt/opsramp/agent/conf/app/discovery/auto-container-detection.yaml

- name: tomcat
  container-checks:
    image-check:
      - tomcat
    port-check:
      - 8080
  mon-type: "jmx"
  misc:
    jmx-port: "7199"

Kubernetes environment

Configure the application in config.yaml

- name: tomcat
  container-checks:
    image-check:
      - tomcat
    port-check:
      - 8080
  mon-type: "jmx"
  misc:
    jmx-port: "7199"

Validate

Go to Resources under the Infrastructure tab to check if your resources are onboarded and the metrics are collected.

Metrics

OpsRamp MetricMetric Display NameUnit
tomcat_maxThreads

Maximun Number of threads created
Max Threadsthreads
tomcat_currentThreadCount

Number of threads currently active
Current Thread Countthreads
tomcat_currentThreadsBusy

Number of busy threads
Current Threads Busythreads
tomcat_jspCount

Number of times JSPs were accessed on all the applications
Jsp Count
tomcat_jspReloadCount

Number of times JSPs were reloaded on all the applications
Jsp Reload Count
tomcat_Servlet_requestCount

Number of requests served by the servlet
Servlet RequestcountRequests
tomcat_Servlet_errorCount

Number of erroneous requests received by the servlet
Servlet ErrorcountErrors
tomcat_Servlet_processingTime

Amount of processing time taken
Servlet ProcessingtimeProcessing Time
tomcat_bytesSent

Megabytes sent by all the request processors running on the Apache Tomcat
Bytes Sentmegabytes
tomcat_bytesReceived

Megabytes received by all the request processors running on the Apache Tomcat
Bytes Receivedmegabytes
tomcat_errorCount

Errors on all the request processors running on the Apache Tomcat
Error CountErrors
tomcat_requestCount

Requests on all the request processors running on the Apache Tomcat
Request CountRequests
tomcat_maxTime

The longest request processing time in milliseconds
Max Timemilliseconds
tomcat_processingTime

Amount of processing time taken
ProcessingtimeProcessing Time
tomcat_jvm_HeapMemoryUsage_commited

Heap memory committed in MB for the server
Jvm Heap Memory Usage Commitedmegabytes
tomcat_jvm_HeapMemoryUsage_used

Heap memory usage in MB of the server
Jvm Heap Memory Usage Usedmegabytes
tomcat_jvm_NonHeapMemoryUsage_commited

Non heap memory committed in MB for the server
Jvm Non Heap Memory Usage Commitedmegabytes
tomcat_jvm_NonHeapMemoryUsage_used

Non heap memory usage in MB of the server
Jvm Non Heap Memory Usage Usedmegabytes
tomcat_jvm_OpenFileDescriptorCount

Number of Open file descriptors of the server
Jvm Open File Descriptor CountOpen FDs
tomcat_jvm_ThreadCount

Number of threads
Jvm Threadcountthreads
tomcat_jvm_Uptime

Uptime of the server
Jvm UptimeMinutes
tomcat_Cache_accessCount

Number of times the cache was accessed
Cache AccesscountAccesses
tomcat_cache_hitsCount

Number of times the cache was hit
Cache HitscountHits
tomcat_StringCache_hitsCount

The number of string cache hits
String Cache HitscountAccesses
tomcat_StringCache_accessCount

The number of accesses to the string cache
String Cache AccesscountHits
tomcat_activeSessions

Number of active sessions to the server
Active SessionsSessions