Tuesday, October 6, 2009

Correlating UNIX processes with Oracle sessions

If we want to move outside of Oracle and see details for the session at the UNIX level, we must correlate the Oracle PIS with the UNIX PID. To see details of these processes you can write an Oracle script to filter the UNIX ps output to only include these processes:

#/bin/ksh
sqlplus system/oracle@prodlive<set pages 999
set feedback off
set echo off
set heading off

spool /tmp/run_pid.ksh

select
'ps -ef|grep '||spid||’grep –v grep’
from
v\$process
where
spid is not NULL
;

spool off;
!

# Execute the UNIX commands . . . .
chmod +x /tmp/*.ksh

Here is the output from this script. As we see, the SQL*Plus script builds the UNIX ps command for the Oracle PIDs and then executes the command.

root> /tmp/run_pid.ksh

jjahn 3231 3129 0 08:12:17 ? 0:00 oraclePA

bbeckero 2482 2377 0 07:59:26 ? 0:00 oraclePA

scarf 2376 785 0 07:59:03 ttyp9 0:00 telnetd

brobins 2377 2376 0 07:59:04 ttyp9 0:01 runmenu50 pamenu

monte 1372 1 0 Sep 21 ? 5:58 /opt/hpnp/bin/hpnpd

imels 1886 1878 0 Sep 21 ttyp1 0:00 tee -a

This script allows us to see the start time for the UNIX connection and also see the cumulative CPU consumption for each task.

No comments:

Post a Comment