denrepo

OracleSessions

Session count by user and machine

Who is connected, from where, and how many are active. The quickest way to spot a connection pool that has run away.

All RAC instances

Not yet verified. How scripts are tested

ora-session-counts.sql
1CLEAR COLUMNS2SET LINESIZE 140 PAGESIZE 100 TRIMOUT ON TAB OFF3COLUMN inst_id  HEADING "INST"     FORMAT 9994COLUMN username FORMAT A205COLUMN machine  FORMAT A35 TRUNCATE6COLUMN total    HEADING "SESSIONS" FORMAT 99,9907COLUMN active   HEADING "ACTIVE"   FORMAT 99,9908 9SELECT inst_id, username, machine,10       COUNT(*) AS total,11       SUM(CASE WHEN status = 'ACTIVE' THEN 1 ELSE 0 END) AS active12FROM gv$session13WHERE type = 'USER'14GROUP BY inst_id, username, machine15ORDER BY total DESC;

Save it as ora-session-counts.sql and run it with SQL> @ora-session-counts.

Open in denrepo

Helps with

Part of these runbooks

More Oracle scripts: Sessions