Identify Top CPU / Memory intensive process and map to corresponding Oracle Process/ Session

Identify Top  CPU / Memory intensive process and map to corresponding Oracle Process/ Session

 $top
hit Shift + f , then choose the display to order by memory usage by hitting key "n" then press Enter.
You will see active process ordered by memory usage

List and Sort Processes by Memory Usage Percentage:

$ps -e -o pmem,pcpu,pid,cmd | sort -k 1 -nr | head -10

$ ps aux | awk '{print $2, $4, $11}' | sort -k2rn | head -n 10
or
$ ps aux |head -1 &&  ps aux|sort -k4rn |head -n 10


List and Sort Processes by CPU Usage Percentage:
$ ps aux | awk '{print $2, $3, $11}' | sort -k2rn | head -n 10
or
$ps aux |head -1 &&  ps aux|sort -k3rn |head -n 10



Using the process id from above , check oracle session related information using sqlplus 

use the command below to set the time format

alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';

select s.sid, s.serial#, s.sql_id, s.machine, s.status, s.process , s.logon_time, s.event , s.username
from
v$process p, v$session s
where
s.paddr=p.addr
and p.spid =processid

processid is Top  CPU / Memory intensive process )

refer the below page to map to individual SQL

Identify Oracle Process ID and related SQL




1 comment: