15 January,2015 by Tom Collins
How do I get DB2 connection count ?I need this information to supply a application restart workflow. Rather than just issuing a db2stop force, I want to send a response to the workflow program , which issues the message to the Operator. The Operator can decide on the a course of action.
For example, there may be a backup in progress or an application may not have been shut down successfully.
Answer: There are a number of methods provided by DB2 to supply the connection details. The decision on approach depends on specific requirements and tolerance for precision.
In your case, you simply need a method to indicate that not only are the databases active but there are connections. You’re requesting whether there is a connection count greater than 0, for a database.
A problem to overcome is differentiating between an explicit and implicit database activation. For example, if a database is active , it is possible a DBA has executed a db2 activate db .This activity would be defined as an explicit activation
As opposed to an application requesting a connection which implicitly activates the database.
You can check all these impacts by using the list active databases command . If the database is active, it will appear in the list. If there is a connection, there will be a number greater than 0 on the Application connected currently value.
Explore these commands , return the information and assess how relevant it is to you’re requirement. I prefer using the db2pd methods, as they use a latch free method of accessing the data required.
--check how long the database is active Db2pd –alldbs – db2pd -alldatabases -bufferpools | grep Database db2 list active databases --Look at the snapshot for the database manager db2 -v get snapshot for database manager db2 -v get snapshot for database manager | grep ‘Applications connected currently’
DB2 database hangs on db2 connect - use db2pd to troubleshoot
DB2 block all connections to a database - svcename - DBA DB2
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |