Orabbix 監控oracle資料表空間 Low Level Discovery

來源:互聯網
上載者:User

標籤:Oracle 資料表空間監控


  1.  在被監控端建立指令碼,此指令碼用於擷取資料表空間及空間使用資訊,此指令碼由oracle使用者下建立

vim mornitor_tbs.sh


#!/bin/bashsource /home/oracle/.bash_profilesqlplus -s zabbix/zabbix > /tmp/tablespace.log<<EOFset linesize 140 pagesize 10000col "Status" for a10col "Name" for a25col "Type" for a10col "Extent" for a15SELECT d.status            "Status",d.tablespace_name   "Name",d.contents          "Type",d.extent_management "Extent",NVL(a.bytes, 0) "Size (M)",NVL(a.bytes - NVL(f.bytes, 0), 0) "Used (M)",round(NVL((a.bytes - NVL(f.bytes, 0)) / a.bytes * 100, 0), 2) "Used %"FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytesfrom dba_data_filesgroup by tablespace_name) a,(select tablespace_name, sum(bytes) bytesfrom dba_data_filesgroup by tablespace_name) a,(select tablespace_name, sum(bytes) bytesfrom dba_free_spacegroup by tablespace_name) fWHEREd.tablespace_name = a.tablespace_name(+)AND d.tablespace_name = f.tablespace_name(+)AND d.tablespace_name not in ('SYSAUX', 'SYSTEM')AND NOT(d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')UNION ALLSELECT d.status            "Status",d.tablespace_name   "Name",d.contents          "Type",d.extent_management "Extent",NVL(a.bytes, 0) "Size (M)",NVL(t.bytes, 0) "Used (M)",round(NVL(t.bytes / a.bytes * 100, 0), 2) "Used %"FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytesfrom dba_temp_filesgroup by tablespace_name) a,(selecttablespace_name, sum(bytes_cached) bytesfrom v\$temp_extent_poolgroup by tablespace_name) tWHEREd.tablespace_name = a.tablespace_name(+)AND d.tablespace_name = t.tablespace_name(+)ANDd.extent_management like 'LOCAL'AND d.contents like 'TEMPORARY'ORDER BY 7;EOFsed -i '$d' /tmp/tablespace.logsed -i '$d' /tmp/tablespace.logsed -i 's/,//g' /tmp/tablespace.log

2. 利用指令碼(oracle_discovery.sh)對取出資料檔案(tablespace.log)進行格式化(因為zabbix自動探索資料類型是jason類型),取出Name那一列,後面配置zabbix自動探索用於自訂宏擷取資料表空間名稱

vim ora_discovery.sh

#!/bin/bashTABLESPACE=`cat /tmp/tablespace.log |awk '{print$2}'|awk 'NR>3{print}'`COUNT=`echo "$TABLESPACE" |wc -l`INDEX=0echo '{"data":['echo "$TABLESPACE" | while read LINE; doecho -n '{"{#TBSNAME}":"'$LINE'"}'INDEX=`expr $INDEX + 1`if [ $INDEX -lt $COUNT ]; thenecho ','fidoneecho ']}

3. 利用指令碼(oracle_check.sh)擷取資料檔案(tablespace.log)後三列

vim oracle_check.sh



#!/bin/bashEQ_DATA="$2"ZBX_REQ_DATA_TAB="$1"SOURCE_DATA=/tmp/tablespace.logcase $2 inmaxmb) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $5}';;used) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $6}';;autopercent) grep -Ew "$ZBX_REQ_DATA_TAB" $SOURCE_DATA |awk '{print $7}';;*) echo $ERROR_WRONG_PARAM; exit 1;;esacexit 0

4. zabbixagent設定檔添加自訂監控key

vim /etc/zabbix/zabbix_agentd.d/userparameter_oracle.conf

    UserParameter=ora.tbs.discovery,/etc/zabbix/zabbix_agentd.d/oracle_discovery.sh

    UserParameter=tablespace[*],/etc/zabbix/zabbix_agentd.d/oracle_check.sh $1 $2


5. 配置計劃任務,重啟zabbix_agentd服務


*/10 * * * * /app/scripts/monitor_tbs.sh > /app/scripts/monitor_tbs.log


6. 在zabbix_server端添加discovery模板,之前安裝過orabbix,直接在Template_Oracle下添加discovery rule

Configuration-> Template->Template_Oracle->Discovery Rules-> Create Discovery Rule


建立Item prototypes

Name :{#TBSNAME} Autopercent

Key :tablespace[{#TBSNAME},autopercent]



Orabbix 監控oracle資料表空間 Low Level Discovery

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.