zabbix通過Orabbix監控oracle數據庫


   orabbix是一個用來監控Oracle數據庫性能的zabbix插件工具,通過安裝在被監控服務器上客戶端上收集數據並傳給zabbix服務器端,然后通過調用圖形顯示.

它是通過JDBC監控數據庫的

 

 能對以下進行監控:

  • DB Version (i.e. Validity of package)
  • Archiving (Archive log production with trend analysis)
  • Event Waits (Files I/O, single block read, multi-block read, direct path read, SQLNet Messages, Control file I/O, Log Write)
  • Hit Ratio (Hit Ratio on Triggers, Tables/Procedures, SQL Area, Body)
  • Logical I/O (Server performance on Logical I/O of: Current Read, Consistent Read, Block Change)
  • Physical I/O (Redo Writes, Datafile Writes, Datafile Reads)
  • PGA
  • SGA (In particular; Fixed Buffer, Java Pool, Large Pool, Log Buffer, Shared Poolm Buffer Cache)
  • Shared Pool (Pool Dictionary Cache, Pool Free Memory, Library Chache, SQL Area, MISC.)
  • Pin Hit Ratio (Oracle library cache pin are caused by contention with the library cache, the area used to store SQL executables for re-use)
  • Sessions / Processes
  • Sessions (Active Sessions, Inactive Sessions, System Sessions)
  • DBSize/DBFileSize (DBSize size of database really used space and of Filesize)

 

1. 需要的條件

  • Zabbix Server    -->這里我使用的是zabbix-3.2.6
  • Java Runtime Environment   -->我用的是dk1.7.0_80

2. 安裝orabbix

  2.1 下載orabbix

http://sourceforge.net/projects/orabbix/files/orabbix-1.2.3.zip/download

mkdir /opt/orabbix
mv orabbix-1.2.3.jar /opt/orabbix
cd /opt/orabbix
unzip orabbix-1.2.3.zip 

 2.2  添加服務啟動腳本,和相關腳本賦權

cp /opt/orabbix/init.d/orabbix /etc/init.d/
chmod u+x /etc/init.d/orabbix
chmod u+x /opt/orabbix/run.sh
chkconfig --add orabbix
chkconfig orabbix on

  run.sh還需要進行修改,將java改成你的JDK中java命令的絕對路徑

/usr/java/jdk1.7.0_80/bin/java -Duser.language=en -Duser.country=US -Dlog4j.configuration=./conf/log4j.properties -cp $(for i in lib/*.jar ; do echo -n $i: ; done).:./orabbix-1.2.3.jar com.smartmarmot.orabbix.bootstrap start ./conf/config.props &

  

    2.3 在oracle數據庫上創建zabbix用戶,並授權

 CREATE USER zabbix
 IDENTIFIED BY zabbix
 DEFAULT TABLESPACE SYSTEM
 TEMPORARY TABLESPACE TEMP
 PROFILE DEFAULT
 ACCOUNT UNLOCK;
 – 2 Roles for ZABBIX
 GRANT CONNECT TO ZABBIX;
 GRANT RESOURCE TO ZABBIX;
 ALTER USER ZABBIX DEFAULT ROLE ALL;
 – 5 System Privileges for ZABBIX
 GRANT SELECT ANY TABLE TO ZABBIX;
 GRANT CREATE SESSION TO ZABBIX;
 GRANT SELECT ANY DICTIONARY TO ZABBIX;
 GRANT UNLIMITED TABLESPACE TO ZABBIX;
 GRANT SELECT ANY DICTIONARY TO ZABBIX;

  如果需要嚴格的權限控制,可以執行如下腳本

CREATE USER zabbix
IDENTIFIED BY zabbix
DEFAULT TABLESPACE USERS
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
GRANT ALTER SESSION TO ZABBIX;
GRANT CREATE SESSION TO ZABBIX;
GRANT CONNECT TO ZABBIX;
ALTER USER ZABBIX DEFAULT ROLE ALL;
GRANT SELECT ON V_$INSTANCE TO ZABBIX;
GRANT SELECT ON DBA_USERS TO ZABBIX;
GRANT SELECT ON V_$LOG_HISTORY TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON SYS.DBA_AUDIT_SESSION TO ZABBIX;
GRANT SELECT ON V_$LOCK TO ZABBIX;
GRANT SELECT ON DBA_REGISTRY TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$SYSSTAT TO ZABBIX;
GRANT SELECT ON V_$PARAMETER TO ZABBIX;
GRANT SELECT ON V_$LATCH TO ZABBIX;
GRANT SELECT ON V_$PGASTAT TO ZABBIX;
GRANT SELECT ON V_$SGASTAT TO ZABBIX;
GRANT SELECT ON V_$LIBRARYCACHE TO ZABBIX;
GRANT SELECT ON V_$PROCESS TO ZABBIX;
GRANT SELECT ON DBA_DATA_FILES TO ZABBIX;
GRANT SELECT ON DBA_TEMP_FILES TO ZABBIX;
GRANT SELECT ON DBA_FREE_SPACE TO ZABBIX;
GRANT SELECT ON V_$SYSTEM_EVENT TO ZABBIX;

  如果是oracle11g用戶還需要開放ACL訪問控制

exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve');
 exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*');
 commit;

  可以運行下面的語句確保上面的沒有問題

select utl_inaddr.get_host_name('127.0.0.1') from dual;

  2.4 創建配置文件config.props

cd /opt/orabbix/conf/
cp /opt/orabbix/conf/config.props.sample config.props

  配置參數

[root@lanmp conf]# cat config.props|grep -v '^#|^$'
#comma separed list of Zabbix servers
ZabbixServerList=ZabbixServer1
ZabbixServer1.Address=192.168.0.95
ZabbixServer1.Port=10051

#pidFile
OrabbixDaemon.PidFile=./logs/orabbix.pid
#frequency of item's refresh
OrabbixDaemon.Sleep=300
#MaxThreadNumber should be >= than the number of your databases
OrabbixDaemon.MaxThreadNumber=100

#put here your databases in a comma separated list
DatabaseList=oracledb

#Configuration of Connection pool
#if not specified Orabbis is going to use default values (hardcoded)
#Maximum number of active connection inside pool
DatabaseList.MaxActive=10
#The maximum number of milliseconds that the pool will wait 
#(when there are no available connections) for a connection to be returned 
#before throwing an exception, or <= 0 to wait indefinitely. 
DatabaseList.MaxWait=100
DatabaseList.MaxIdle=1

#define here your connection string for each database
oracledb.Url=jdbc:oracle:thin:@192.168.0.92:1521:dbsrv1
oracledb.User=zabbix
oracledb.Password=zabbix
#Those values are optionals if not specified Orabbix is going to use the general values
oracledb.MaxActive=10
oracledb.MaxWait=100
oracledb.MaxIdle=1
oracledb.QueryListFile=./conf/query.props

  PS:

    DatabaseList中放的是被監控的數據庫主機名,該名稱要和zabbix server界面中的機器名稱保持一致

2.5 啟動orabbix

[root@lanmp orabbix]# service orabbix start
Starting Orabbix service:

  查看啟動的進程

[root@lanmp orabbix]# ps aux |grep orabbix
root     25572 35.0  2.3 1295872 45084 pts/2   Sl   15:54   0:00 /usr/java/jdk1.7.0_80/bin/java -Duser.language=en -Duser.country=US -Dlog4j.configuration=./conf/log4j.properties -cp lib/commons-codec-1.4.jar:lib/commons-dbcp-1.4.jar:lib/commons-lang-2.5.jar:lib/commons-logging-1.1.1.jar:lib/commons-pool-1.5.4.jar:lib/hsqldb.jar:lib/log4j-1.2.15.jar:lib/ojdbc6.jar:.:./orabbix-1.2.3.jar com.smartmarmot.orabbix.bootstrap start ./conf/config.props
root     25585  0.0  0.0 103316   844 pts/2    S+   15:54   0:00 grep orabbix

  

3. WEB界面配置

  3.1  導入模板文件

導入模板。模板在/opt/orabbix/template.

                Orabbix_export_full.xml 全部導入(圖表 監控項 觸發器)

                Orabbix_export_graphs.xml 圖表

                Orabbix_export_items.xml 監控項

                Orabbix_export_triggers.xml 觸發器

模板-->導入

如果導入失敗,需要將orabbix的4個xml里面的<group>TEMPLATES</group>改成<group>TEMPLATES_ORACLE</group>,然后重新導入import即可。

  

3.2 將被監控的主機關聯模板

 

 

你會發現有一些監控項dbfilesize,dbsize沒有值,這是因為/opt/orabbix/conf/query.props文件沒有把這兩個加入進查詢的List下面,可以從query.props.sample把這兩項復制進去

 在QueryList最后面加上dbfilesize,dbsize

然后在文件末尾加入:

 

dbfilesize.Query=select to_char(sum(bytes/1024/1024/10), 'FM99999999999999990') retvalue from dba_data_files

dbsize.Query=SELECT to_char(sum( NVL(a.bytes/1024/1024/10 - NVL(f.bytes/1024/1024/10, 0), 0)), 'FM99999999999999990') retvalue \
FROM sys.dba_tablespaces d, \
(select tablespace_name, sum(bytes) bytes from dba_data_files group by tablespace_name) a, \
(select tablespace_name, sum(bytes) bytes from dba_free_space group by tablespace_name) f \
WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+) \
AND NOT (d.extent_management like 'LOCAL' AND d.contents like 'TEMPORARY')

  

 

結果演示:

 

 

 


免責聲明!

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



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