查询Oracle的cpu使用情况,Oracle CPU使用情况曲线

Oracle CPU使用情况曲线

-- alter session set nls_timestamp_format='yyyy-mm-dd hh24:mi:ss:ff';

-- select min(SAMPLE_TIME) from GV$ACTIVE_SESSION_HISTORY;

-- DECODE (STATE,'WAITING', EVENT,'[CPU]:') event from v$session

-- 查看ASH Buffer大小

-- select total_size/1024/1024,awr_flush_emergency_count from v$ash_info;

-- DBA_HIST_ACTIVE_SESS_HISTORY

-- GV$ACTIVE_SESSION_HISTORY

-- GV$SESSION

-- CPU使用情况曲线

-- 动态视图 GV$ACTIVE_SESSION_HISTORY

-- 查询RAC,PDB=3的数据库的使用情况

set line 190 pages 0

alter session set nls_timestamp_format='yyyy-mm-dd hh24:mi:ss:ff';

col SAMPLE_TIME for a16

set numw 6

select

to_char(SAMPLE_TIME,'yyyy-mm-dd hh24:mi') SAMPLE_TIME

,max(case when "Node 1">0 then "Node 1" else null end) node1_max

,max(case when "Node 2">0 then "Node 2" else null end) node2_max

,case when coalesce(count(case when "Node 1">0 then 1 else null end),0)=0 then 0

else round(sum("Node 1")/count(case when "Node 1">0 then 1 else null end),0) end node1_avg

,case when coalesce(count(case when "Node 2">0 then 1 else null end),0)=0 then 0

else round(sum("Node 2")/count(case when "Node 2">0 then 1 else null end),0) end node2_avg

,sum("Node 1") node1_total

,count(case when "Node 1">0 then 1 else null end) node1_num

,min(case when "Node 1">0 then "Node 1" else null end) node1_min

,sum("Node 2") node2_total

,count(case when "Node 2">0 then 1 else null end) node2_num

,min(case when "Node 2">0 then "Node 2" else null end) node2_min

from (

select SAMPLE_TIME,session_state,

count(case when inst_id=1 then 1 else null end) "Node 1",

count(case when inst_id=2 then 1 else null end) "Node 2"

from GV$ACTIVE_SESSION_HISTORY

where session_state='ON CPU'

and con_id=3

group by SAMPLE_TIME,session_state

) t group by to_char(SAMPLE_TIME,'yyyy-mm-dd hh24:mi')

order by 1

;

-- ASH历史信息 DBA_HIST_ACTIVE_SESS_HISTORY

col SAMPLE_TIME for a16

set numw 6

select

to_char(SAMPLE_TIME,'yyyy-mm-dd hh24:mi') SAMPLE_TIME

,sum("Node 1") node1_total

,count(case when "Node 1">0 then 1 else null end) node1_num

,min(case when "Node 1">0 then "Node 1" else null end) node1_min

,max(case when "Node 1">0 then "Node 1" else null end) node1_max

,round(sum("Node 1")/count(case when "Node 1">0 then 1 else null end),0) node1_avg

,sum("Node 2") node2_total

,count(case when "Node 2">0 then 1 else null end) node2_num

,min(case when "Node 2">0 then "Node 2" else null end) node2_min

,max(case when "Node 2">0 then "Node 2" else null end) node2_max

,round(sum("Node 2")/count(case when "Node 2">0 then 1 else null end),0) node2_avg

from (

select

SAMPLE_TIME,SESSION_STATE,

count(case when INSTANCE_NUMBER=1 then 1 else null end) "Node 1",

count(case when INSTANCE_NUMBER=2 then 1 else null end) "Node 2"

from containers(DBA_HIST_ACTIVE_SESS_HISTORY)

where SAMPLE_TIME between to_date('2020-06-30 08:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2020-06-30 18:00:00','yyyy-mm-dd hh24:mi:ss')

and con_id=3 and session_state='ON CPU'

group by SAMPLE_TIME,SESSION_STATE

) t group by to_char(SAMPLE_TIME,'yyyy-mm-dd hh24:mi')

order by 1

;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值