orabbix插件監控oracle表空間問題


 我們安裝好orabbix插件后,查看Tablespaces監控項是發項值為none,第一反應是沒監控成功,其實不然。

1、我們打開orabbix監控項參數的路徑,下面為Tablespaces的sql代碼

[root@-svr1 ~]# vim /opt/orabbix/conf/query.props

select '- Tablespace ->',t.tablespace_name ktablespace, \
       '- Type->',substr(t.contents, 1, 1) tipo, \
       '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024) ktbs_em_uso, \
       '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \
       '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \
       '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024) kfree_space, \
       '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space, 0))/1024/1024) kspace, \
       '- Perc->',decode(d.tbs_maxsize, 0, 0, trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \
from \
  ( select SUM(bytes) tbs_size, \
           SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize, tablespace_name tablespace \
    from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
    from dba_data_files \
    union all \
    select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \
    from dba_temp_files \
    ) \
    group by tablespace_name \
    ) d, \
    ( select SUM(bytes) free_space, \
    tablespace_name tablespace \
    from dba_free_space \
    group by tablespace_name \
    ) s, \
    dba_tablespaces t \
    where t.tablespace_name = d.tablespace(+) and \
    t.tablespace_name = s.tablespace(+) \
    order by 8) \
    where kperc > 93 \
    and tipo <>'T' \
    and tipo <>'U'
tbl_space.NoDataFound=none

這個SQL會返回93%滿的表空間信息,而對應這個監控項,orabbix也定義了觸發器,因為監控項的返回值是文本,而沒有滿足條件的記錄時返回字符串“none“,所以監控項對應的觸發器會檢查返回值開頭是不是none,如果不是,就報警,這樣,用戶除了收到預警信息,還能從返回值的具體值中看到具體時哪個表空間快滿了。

改為3%后測試結果:

當然,大部分時間監控項會返回none,所以我們無法畫出正常未滿的表空間的空間占用時間曲線。只有超過93%慢時,我們才知道具體的占用情況。

如果想收集並保留更多信息,就需要使用自定義查詢,方法就是在query.props文件中加入你想檢查的SQL,比如我們想了解表空間信息,就加以下SQL:

customtbl.Query=select 'TBL:'||a.tablespace_name||',' TBL, \

'Total Size:'||trunc(sum(a.tots) / 1024 / 1024, 2)||',' Tot_Size_mb, \

'Free MB:'||round(sum(a.sumb) / 1024 / 1024, 2)||',' Tot_Free_mb, \

'PCT Free:'||round(sum(a.sumb) * 100 / sum(a.tots), 2)||',' Pct_Free, \

'Max Free MB:'||round(sum(a.largest) / 1024 / 1024, 2)||',' Max_Free_mb, \

'Chunks Free:'||sum(a.chunks)||',' Chunks_Free \

from (select tablespace_name, \

0 tots, \

sum(bytes) sumb, \

max(bytes) largest, \

count(*) chunks \

from dba_free_space a \

group by tablespace_name \

union \

select tablespace_name, sum(bytes) tots, 0, 0, 0 \

from dba_data_files \

group by tablespace_name) a \

group by a.tablespace_name

customtbl.NoDataFound=none

 

 



 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM