Apache Tomcat Monitoring

Tomcat server monitoring and performance management made easy with Site24x7 plugins.

Start 30-day free trial Try now, sign up in 30 seconds

Efficient monitoring of your Apache Tomcat servers is essential as poor performance can have a direct influence on the end-user experience. With Site24x7 Tomcat plugin, get a detailed view of all the critical Tomcat service metrics in a single, intuitive dashboard.

This document details how to configure the Apache Tomcat plugin and the monitoring metrics for providing in-depth visibility into the performance, availability, and usage stats of Tomcat servers.

Monitoring Metrics

The performance metrics for Tomcat falls under three categories: thread pool metrics, overall memory metrics, and usage metrics for each memory pool.

Total number of threads

thread_count is critical for tracking the resource consumption. This helps to prevent bottlenecks and detect thread pool exhaustion.

Busy threads count and total number of threads allowed

Comparing the metrics thread_busy and thread_count with thread_allowed gives an idea on the resource consumption.

Bytes received and bytes sent

Relate the thread count metrics with the bytes_received and bytes_sent to know the capacity of your web server.

Total number of errors

error_count gives the number of errors per second on all request processors.

Number of requests

The request_count metric gives the number of requests per second across all request processors.

Free Memory

The free_memory shows the amount of heap space currently available to the Java Virtual Machine (JVM).

Maximum Memory

The max_memory is the maximum size of the heap space not including the permanent generation area.

Time taken for processing the request

The sum of request processing times across all requests handled by the request processors is shown under processing_time.

Total Memory

The total_memory is the memory currently allocated to the JVM heap space.

Usage stats of each memory pool

Data from the metric usage_"name of the memory pool" gives the user a quick look on the memory usage. This can help manage memory resources proactively and resolve downtimes in production.

Prerequisites

  • Download and install the Site24x7 server monitoring agent (Linux | Windows) in the server where you plan to run the plugin.
  • For Linux servers, follow the steps below:
    • Navigate to the following directory: /opt/tomcat/conf
    • Open the tomcat-users.xml file.
    • Ensure the following roles are added to the user:
      <user username="user" password="user" roles="manager-gui,admin-gui"/>
      <user username="user" password="user" roles="manager-script"/>
    • Restart the Tomcat server.
  • For Windows servers, follow the steps below:
    • Navigate to the following directory: <tomcat_dowloaded_directory>\conf
    • Open the tomcat-users.xml file.
    • Remove the Manager Page restriction (applies only to Tomcat 8 and above):
      i. Open the context.xml file.
      vi /opt/tomcat/webapps/manager/META-INF/context.xml
      ii. Find the following code block:
      <Valve className="org.apache.catalina.valves.RemoteAddrValve"
      allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
      <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.Csr>
      iii. Comment the code block:
      ...
      <Context antiResourceLocking="false" privileged="true" >
      <CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
      sameSiteCookies="strict" />
      <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve"
      allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> -->
      <Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.Csr>
      </Context>
    • Follow the same steps mentioned above for removing the Host Manager Page restriction:
      vi /opt/tomcat/webapps/host-manager/META-INF/context.xml
    • Restart the Tomcat server.

Plugin Installation

  • To monitor Tomcat connectors, create a folder named tomcat_connector.
  • Download all the files from our GitHub respository and place them in the tomcat_connector folder.
    wget https://raw.githubusercontent.com/site24x7/plugins/master/tomcat_connector/tomcat_connector.py
    wget https://raw.githubusercontent.com/site24x7/plugins/master/tomcat_connector/tomcat_connector.cfg
  • To check if the plugin is working, execute the command below and check for a valid JSON output with applicable metrics and their corresponding values.
    python tomcat_connector.py --host='hostname' --port='port' --username='username' --password='password'
  • Add the applicable configurations in the tomcat_connector.cfg file:
    [1]
    host = 'localhost'
    port = '8080'
    username = 'admin'
    password = 'admin'
  • Follow the steps in this article to learn how to run the Python script on a Windows server. You don't need to do this for Linux.
  • Move the tomcat_connector folder to the Site24x7 server monitoring plugin directory.

    For Linux: /opt/site24x7/monagent/plugins/

    For Windows: C:\Program Files (x86)\Site24x7\WinAgent\monitoring\plugins\

  • Note: The prerequisites and installation steps mentioned above apply to the Tomcat overall memory and the Tomcat memory pool plugins as well. Download the files from our GitHub repository (Tomcat overall memory, Tomcat memory pool) and follow the steps in the README files to install the plugins.
The agent will automatically execute the plugin within five minutes and display the performance data in Site24x7.
To view the plugin monitor and associated performance charts:
  • Log in to Site24x7.
  • Navigate to Plugins and click the required monitor.

Plugin Contribution

Feel free to contribute to our existing plugin and come up with suggestions or feedback on our Community.

Featured
Complete guide to monitoring Apache performance

Monitoring services for uptime and performance is a crucial part of any organization’s day-to-day operations. Understand your Apache HTTPD server better and learn how to ensure that it is being fully monitored.