You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否通过SNMP获取JDBC连接池的属性值?

Can You Retrieve Catalina JDBC Connection Pool Properties via SNMP?

Great question! The short answer is yes, it's possible—but the default JVM-MANAGEMENT-MIB you're using won't get you there, which explains why your snmpwalk command didn't return JDBC connection pool data. Let's break down why and how to fix this:

Why Your Current Command Isn't Working

The OID .1.3.6.1.4.1.42.2.145.3.163.1.1 maps to the standard JVM Management MIB, which only covers core JVM metrics (like memory pools such as PS Eden Space, thread counts, garbage collection stats). It has no visibility into Tomcat/Catalina-specific resources like JDBC connection pools, which are application-layer components.

How to Get Catalina JDBC Connection Pool Data via SNMP

You have two reliable paths to access this data:

1. Use Tomcat's Built-in CATALINA-MIB

Tomcat includes a dedicated MIB (CATALINA-MIB) that exposes Catalina-specific metrics, including JDBC connection pool properties. Here's how to set it up:

  • Enable the SNMP Listener in Tomcat: Edit your conf/server.xml and add the SnmpListener listener to expose the Catalina MIB:
    <Listener className="org.apache.catalina.mbeans.SnmpListener"
              port="11111"
              community="public"
              version="2c"
              snmpOid=".1.3.6.1.4.1.18060"/>
    
  • Verify the MIB is Available: Ensure Tomcat's lib directory contains tomcat-snmp.jar (this is included in standard Tomcat distributions for supported versions).
  • Query the Correct OID Branch: Once configured, you can walk the Catalina MIB's connection pool OID branch (typically .1.3.6.1.4.1.18060.1.2.2) to retrieve data like connection pool names, active connections, max connections, and more. Try this command:
    snmpwalk -On -Cc -v 2c -c public 127.0.0.1:11111 .1.3.6.1.4.1.18060.1.2.2
    

2. Bridge JMX to SNMP (Custom Solution)

If you need more control over which metrics are exposed, you can use a tool like SNMP4J-JMX to bridge Tomcat's JMX MBeans to SNMP. Tomcat exposes JDBC connection pool metrics via JMX under the Catalina:type=DataSource MBean tree. With this approach:

  • Map the JMX attributes (e.g., numActive, maxActive, name) to custom SNMP OIDs.
  • Deploy the bridge to translate JMX data into SNMP-readable format, then query those custom OIDs.

Final Notes

The default JVM MIB was never designed to expose application-specific resources like Tomcat's JDBC pools. Using Tomcat's native CATALINA-MIB is the simplest, most supported way to get this data via SNMP.

内容的提问来源于stack exchange,提问作者Jdamian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 08:26:13