--   FILE:    dispusr.sql
--
--   AUTHOR:  Andy Rivenes, arivenes@appsdba.com
--            Copyright (c) 1998-2005, AppsDBA Consulting. All Rights Reserved.
--
--   DATE:    11/06/98
--
--   DESCRIPTION:
--            This script will list users currently logged on to the system.
--
--   REQUIREMENTS:
--
--
--   MODIFICATIONS:
--            A. Rivenes, 01/27/2000, Added Oracle PID
--            A. Rivenes, 04/23/2004, Increased the column width for the client
--                                    process.
--            A. Rivenes, 08/25/2005, Added client_identifier, client_info, module,
--                                    action, and service_name columns, commented out
--                                    PID, osuser, server, process and program.
--
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
-- 
--
SET PAGESIZE 9999;
SET VERIFY off;
SET FEEDBACK off;
SET LINESIZE 132;
--
COLUMN uname      HEADING  'User|Name'               FORMAT A11;
COLUMN sid        HEADING  'Oracle|SID'              FORMAT 999999;
COLUMN pid        HEADING  'Oracle|PID'              FORMAT 999999;
COLUMN sernum     HEADING  'Serial#'                 FORMAT 999999;
COLUMN spid       HEADING  'Server|PID'              FORMAT 999999;
COLUMN suser      HEADING  'Client|OS User'          FORMAT A8;
COLUMN clid       HEADING  'Client|Identifier'       FORMAT A10;
COLUMN status     HEADING  'Status'                  FORMAT A8;
COLUMN server     HEADING  'Server'                  FORMAT A9;
COLUMN smach      HEADING  'Client|Machine'          FORMAT A15   WORD_WRAPPED;
COLUMN process    HEADING  'Client|Process'          FORMAT A9;
COLUMN sprog      HEADING  'Program'                 FORMAT A15   WORD_WRAPPED;
COLUMN clinfo     HEADING  'Client|Info'             FORMAT A15   WORD_WRAPPED;
COLUMN mod        HEADING  'Module'                  FORMAT A9;
COLUMN act        HEADING  'Action'                  FORMAT A9;
COLUMN srvnm      HEADING  'Service|Name'            FORMAT A15   WORD_WRAPPED;
--
SELECT a.username uname,
       a.sid sid,
--       b.pid pid,
       a.serial# sernum,
       b.spid spid,
--       a.osuser suser,
       a.status status,
       a.client_identifier clid,
--       a.server server,
       a.machine smach,
--       a.process process,
--       a.program sprog,
       a.client_info clinfo,
       a.module mod,
       a.action act,
       a.service_name srvnm
  FROM v$session a, 
       v$process b
 WHERE a.paddr = b.addr
   AND a.type != 'BACKGROUND'
/

