關於oracle監控cpu使用率,sga使用率,io吞吐量的查詢語句

前言

       今天老大叫我做一個模塊,功能用於進行數據庫監控,監控的內容包括:CPU使用率、i/O吞吐量、SGA使用率等等。還要監控JAVA應用服務器的CPU使用率、i/O吞吐量、SGA使用率等等(這個內容不在本文討論範疇)。

       我從業以來,第一次做關於服務器性能的監控,有幸CSDN的大佬提供的豐富的解決文章讓我能夠順利解決技術層面的難題,在此感謝大家!!你們真的很棒!!

       通過一個下午的奮鬥,終於讓我解決了這個問題。說真的,本來以爲是個簡單的工作,深入理解之後才發現沒那麼簡單,要不是大神的幫助,估計這次要涼了。以下爲我的解決方案:

select * from v$osstat;  --cpu使用率

--io吞吐量
select sum(decode(name,'physical read IO requests',value,'physical write IO requests',value,0)) as iops,
sum(decode(name,'physical read bytes',value,'physical write bytes',value,0)) / 1024 / 1024 as mbps from v$sysstat
where name in ('physical read IO requests','physical write IO requests','physical read bytes','physical read total bytes',
'physical write bytes','physical write total bytes','physical read total IO requests','physical write total IO requests');
--sga使用情況
select name,total,round(total-free,2) used, round(free,2) free,round((total-free)/total*100,2) pctused from
(select 'SGA' name,(select sum(value/1024/1024) from v$sga) total,
(select sum(bytes/1024/1024) from v$sgastat where name='free memory')free from dual)
union
select name,total,round(used,2)used,round(total-used,2)free,round(used/total*100,2)pctused from (
select 'PGA' name,(select value/1024/1024 total from v$pgastat where name='aggregate PGA target parameter')total,
(select value/1024/1024 used from v$pgastat where name='total PGA allocated')used from dual);

 參考文章:https://www.cnblogs.com/ios9/p/9633259.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章