简体   繁体   中英

Monitoring datasource connection pool on Wildfly9

I'm working on the project where I'm trying to get the runtime statistics of my datasource connection pool which I placed into /deployment folder using Wildfly-9. I searched for it and I found the configuration file which exist inside /standalone folder named as standalone.xml file giving me the statistics of datasource connection poool by using below code :

<datasource jta="true" jndi-name="java:jboss/datasources/DemoDS" pool-name="DemoDS" enabled="true" use-ccm="true" statistics-enabled="true">
    <connection-url>jdbc:mysql://localhost:3306/demo?zeroDateTimeBehavior=convertToNull</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>mysql</driver>
        <pool>
            <min-pool-size>1</min-pool-size>
            <max-pool-size>50</max-pool-size>
        </pool>
        <security>
            <user-name>root</user-name>
            <password>root</password>
        </security>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
        <background-validation>true</background-validation>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
    </validation>
</datasource>

Hit this url I got this:

http://localhost:9990/management/subsystem/datasources/data-source/DemoDS/statistics/pool?include-runtime=true

I get the following json string: You get the following json string:

{
   "ActiveCount":4,
   "AvailableCount":48,
   "AverageBlockingTime":0,
   "AverageCreationTime":21,
   "AverageGetTime":17,
   "AveragePoolTime":195196,
   "AverageUsageTime":43,
   "BlockingFailureCount":0,
   "CreatedCount":4,
   "DestroyedCount":0,
   "IdleCount":2,
   "InUseCount":2,
   "MaxCreationTime":47,
   "MaxGetTime":47,
   "MaxPoolTime":386185,
   "MaxUsageTime":134,
   "MaxUsedCount":4,
   "MaxWaitCount":0,
   "MaxWaitTime":0,
   "TimedOut":0,
   "TotalBlockingTime":0,
   "TotalCreationTime":87,
   "TotalGetTime":88,
   "TotalPoolTime":780787,
   "TotalUsageTime":217,
   "WaitCount":0,
   "XACommitAverageTime":0,
   "XACommitCount":0,
   "XACommitMaxTime":0,
   "XACommitTotalTime":0,
   "XAEndAverageTime":0,
   "XAEndCount":0,
   "XAEndMaxTime":0,
   "XAEndTotalTime":0,
   "XAForgetAverageTime":0,
   "XAForgetCount":0,
   "XAForgetMaxTime":0,
   "XAForgetTotalTime":0,
   "XAPrepareAverageTime":0,
   "XAPrepareCount":0,
   "XAPrepareMaxTime":0,
   "XAPrepareTotalTime":0,
   "XARecoverAverageTime":0,
   "XARecoverCount":0,
   "XARecoverMaxTime":0,
   "XARecoverTotalTime":0,
   "XARollbackAverageTime":0,
   "XARollbackCount":0,
   "XARollbackMaxTime":0,
   "XARollbackTotalTime":0,
   "XAStartAverageTime":0,
   "XAStartCount":0,
   "XAStartMaxTime":0,
   "XAStartTotalTime":0,
   "statistics-enabled":true
}

Since I have many datasource file I cannot place into individual standalone.xml file. So anyone knows how I will get the runtime statistics of my datasource connection pool which I placed into /deployment folder?

From Wildfly CLI:

Check if stats enabled for datasource

/subsystem=datasources/data-source=(your datasourcename):read-attribute(name=statistics-enabled)  

Enable stats: requires restart of Wildfly service afterwards

/subsystem=datasources/data-source=(your datasource):write-attribute(name=statistics-enabled, value=true) 

After restart start CLI and run the check command again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM