0

We are using OleDbConnection class to connect Oracle and SqlServer. At some places we are also using SqlClient and Oracle.DataAccess.OracleConnection. I need to know how many active connections our servers have using Performance counter.

Our DBA is blaming us that we are not closing connections. But we are sure that we are closing connection(we are putting connection in C# using).

user960567
  • 329
  • 2
  • 9
  • 17
  • 1
    for sql server you can look at perf_counter["\SQLServer:General Statistics\User Connections"] . take care if you use named instance you have to check with perf monitor. – YuKYuK Sep 06 '16 at 09:38

1 Answers1

0

For Oracle you can use V$SESSION view
https://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2088.htm#REFRN30223

Something like this:

select LOGON_TIME, OSUSER, PROCESS, PROGRAM, MACHINE\
from V$SESSION \
where MACHINE = 'YOUR CLIENT HOSTNAME' and STATUS != 'KILLED';

In case connections are initiated from different clients but from the same Application name - you can filter based on PROGRAM

WHERE regexp_like(PROGRAM,'Your Program Name','i');

Or you can do it based on netstat output.
Like this

netstat -anp | grep ":1521" | grep 'ESTABLISHED' | grep 'Your CLIENT IP' | wc -l

Similar technic based on netstat can be applied on SQL Server

netstat -ano | find /I ":1433" | find /I "ESTABLISHED" | find /I "Your client IP" /c
Dmitry Zayats
  • 1,378
  • 6
  • 7