问题
M newbie to JMeter, Can we track the active DB connections via Jmeter? Is there any parameter or thing in Jmeter which can do the job easier.
Right now I am just monitoring the DB connections via terminal. Is it possible with Jmeter
回答1:
Given that your database is MySQL:
- Download MySQL Connector/J, extract
mysql-connector-java-x.x.xx-bin.jar
, drop it to /lib folder of your JMeter installation, restart JMeter Add Thread Group to the test plan. Configure it as follows:
- Number of threads:
1
- Ramp-up:
1
- Loop Count: tick
Forever
- Number of threads:
Add JDBC Connection Configuration element. Configure it as follows:
- Variable Name: anything meaningful, i.e.
test
- Database URL:
jdbc:mysql://your_mysql_host:3306/information_schema
- JDBC Driver Class:
com.mysql.jdbc.Driver
- provide your credentials as well
- Variable Name: anything meaningful, i.e.
Add JDBC Request Sampler. Configure it the next way:
- Variable Name:
test
or what you have entered in the JDBC Connection Configuration element - SQL Query:
select * from PROCESSLIST;
- Variable Name:
- Add Constant Timer. Set "Thread Delay" to be i.e. 5000
- Add View Results Tree listener
Above config will query MySQL server each 5 seconds and results will go to the View Results Tree listener.
If you use other RDBMS server the approach should be the same, however JDBC driver binary, driver class name, URL and SQL query will be different.
See The Real Secret to Building a Database Test Plan With JMeter for extra information on database testing with Apache JMeter.
来源:https://stackoverflow.com/questions/30148159/how-to-see-db-connections-via-jmeter