Orabbix Monitoring Oracle Table space Low level Discovery

Source: Internet
Author: User


    1. Creates a script on the monitored side that is used to obtain tablespace and space usage information, which is created by the Oracle user

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&NBSP;-&NBSP;NVL ( f.bytes, 0),  0)   "used  (M)", Round (NVL (A.BYTES&NBSP;-&NBSP;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&Nbsp;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. Use the script (oracle_discovery.sh) to format the Fetch data file (Tablespace.log) (because the Zabbix Autodiscover data type is Jason type), remove the Name column, Later configure Zabbix Auto-discovery for custom macros get table space names

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 ' I f [$INDEX-lt $COUNT]; Thenecho ', ' Fidoneecho ']}

3. Use the script (oracle_check.sh) to get the data file (Tablespace.log) after three columns

Vim oracle_check.sh



#!/bin/basheq_data= "$" zbx_req_data_tab= "$" source_data=/tmp/tablespace.logcase $ inmaxmb) grep-ew "$ZBX _req_data _tab "$SOURCE _data |awk ' {print $} ';; 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 configuration file Add custom monitoring 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 $


5. Configure scheduled Tasks, restart the ZABBIX_AGENTD service


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


6. Add Discovery template on the Zabbix_server side, previously installed Orabbix, add Discovery rule directly under Template_oracle

configuration-> template->template_oracle->discovery rules-> Create Discovery Rule


Create Item Prototypes

Name: {#TBSNAME} autopercent

Key:tablespace[{#TBSNAME},autopercent]



Orabbix monitoring Oracle Tablespace low level Discovery

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.