tomcat-users mailing list archives

Re: Best way to find out how many DB connections that are open at any given time

Date

Tue, 10 Jan 2017 16:24:31 GMT

On 10.01.2017 17:10, Joleen Barker wrote:
> Hello All,
>
> Details:
> Tomcat Version: 7.0.64.0
> Java Version: 1.8.0
> OS: AIX 6.1
> Database: Oracle 11
>
> The web application installed on the server above makes data connections to
> run file transfers from point A to point B. The default Database connection
> setting that are set when the application server comes up are as follows:
>
> DataBasePoolingFlag - APACHE
> MaxActive - 400
> MaxIdle - 20
> MinIdle - 10
>
> We had an incident where all these connections were actually used up due to
> a script someone had that looped. I need to determine at any given point in
> time how many DB connections exist from the web application to the DB.
> There may be more than one way to do this. I am sure there is a DB command
> that could be run against the schema but the schema is pointed to by many
> servers. I am wondering if there is a java command of some kind that I
> could run that may tell me how many connections are open at that time or
> possibly a tomcat or apache command.
>
> Thank you for the help in advance.
>
Hi.
Maybe an "out of the box" answer, not using java.
I don't know how the following commands fare under AIX, but on a Linux system, the
OS-level command :
~# netstat -pan --tcp | grep ESTABLISHED
will show you pretty much all TCP connections that are established between any process and
any other, local or remote.
Sample output :
tcp6 0 0 127.0.0.1:45095 127.0.0.1:11002 ESTABLISHED 11096/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53564 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53677 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53659 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53656 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53620 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:8009 127.0.0.1:53608 ESTABLISHED 2677/java
tcp6 0 0 127.0.0.1:45142 127.0.0.1:11002 ESTABLISHED 11096/java
tcp6 0 0 127.0.0.1:43558 127.0.0.1:11002 ESTABLISHED 11096/java
tcp6 0 0 127.0.0.1:45128 127.0.0.1:11002 ESTABLISHED 11096/java
tcp6 0 0 127.0.0.1:45069 127.0.0.1:11002 ESTABLISHED 11096/java
I presume that you could easily find out the process-id of your Tomcat, and the port
number under which the database is accessed.
It would be a simple matter to "grep" the above and count the lines, to get the answer you
seem to want.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org