Subscribe to Posts by Email

Subscriber Count

    699

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

Database Host Reports Top CPU – 100% – Just a simple rescue script

The situation is, and you just logged 🙂

1. DB Response is slow

2. Top/OEM/Graphs show your database host CPU is pegged to 100%, and (no other things running apart from db)

3. Unfortunately you do not have Active Session History, to fire a magical script , 5 minutes back, 10 minutes back, 

4. You just need to check current statements quickly which just pegging CPU

5. And the Weird things, if you are in Cloud or kind of DBAAS, you just cant do SSH (really) , so you cant find top process ID from TOP

 

So with all conditions above, the following script really really saving my life here 🙂

select 

se.SID, 

ss.serial#,

 ss.username, 

 ss.machine,

 ss.sql_id,

 to_char(s.last_active_time,'DD-MON-YY HH:MI:SS'),

 s.last_load_time, 

 VALUE/100 cpu_usage_seconds ,

 substr(s.sql_text,1,100)

from 

 v$session ss, 

 v$sesstat se, 

 v$statname sn,

 v$sql s

where 

 se.STATISTIC# = sn.STATISTIC# 

and 

 NAME like '%CPU used by this session%' 

and 

 se.SID = ss.SID 

--and 

 --ss.status='ACTIVE' 

--and 

-- ss.username is not null  and ss.username!='DBMANAGER'

and 

ss.sql_id=s.sql_id

order by VALUE desc;

 

And the output, As you see two processes pegging CPU 129 and 40 of about more than 100% (thats actually calculation issue) and what next kill it and save your database.

 

 

And another

1 comment to Database Host Reports Top CPU – 100% – Just a simple rescue script