1. 程式人生 > >zabbix3.4.6之監控Oracle

zabbix3.4.6之監控Oracle

導入 listener 腳本 剛才 重新 fin import 用戶 send

  新zabbix搭建配置完後,公司所有的主機是通過自動註冊完成了添加,網絡設備及其Templates是從舊zabbix中Export出模板,然後Import入新zabbix系統中。一些應用的監控就需要自己重新添加了。

  本以為Oracle監控是通過編寫腳本提取出監控的數值,然後再sender到server端進行監控;後來怎麽也找不到舊的監控腳本,咨詢了一下DBA同事,說是Oracle應該有一個特定的zabbix監控插件,百度一下發現了Orabbix插件,那就去看一看官方文檔。

  orabbix是需要java運行環境的,所以需要安裝JDK。

添加zabbix用戶

首先在oracle中創建zabbix用戶,可以使用下面腳本;

CREATE USER ZABBIX
IDENTIFIED BY <REPLACE WITH PASSWORD>
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版本,還需要加入下列:

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;

安裝部署orabbix

mkdir /usr/local/orabbix
cd /usr/local/orabbix
wget https://jaist.dl.sourceforge.net/project/orabbix/orabbix-1.2.3.zip
unzip orabbix-1.2.3.zip
chmod +x
/usr/local/orabbix/run.sh

  init.d目錄下的orabbix腳本,這個腳本是初始化腳本,不需要此功能就不用改。腳本中orabbix賦為安裝路徑,默認為orabbix=/opt/orabbix,需要改成你安裝的路徑,根據我剛才的部署,所以要改為orabbix=/usr/local/orabbix。

  run.sh腳本是一個java命令,如果你的JDK是源碼編譯安裝,這兒就需要將腳本中的java改為指向java的絕對路徑。

配置文件  

conf目錄下都是配置文件樣例,需要cp一份再進行配置

cp /user/local/orabbix/conf/config.props.sample /user/local/orabbix/conf/config.props
#comma separed list of Zabbix servers
ZabbixServerList=zabbix_server

ZabbixServer1.Address=172.85.10.51
ZabbixServer1.Port=10051

#ZabbixServer2.Address=IP_ADDRESS_OF_ZABBIX_SERVER
#ZabbixServer2.Port=PORT_OF_ZABBIX_SERVER

#pidFile
OrabbixDaemon.PidFile=./logs/orabbix.pid
#frequency of items 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=172.87.100.11,172.87.100.12

#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
DB1.Url=jdbc:oracle:thin:@server.domain.example.com:<LISTENER_PORT>:DB1
DB1.User=zabbix
DB1.Password=zabbix_password
#Those values are optionals if not specified Orabbix is going to use the general values
DB1.MaxActive=10
DB1.MaxWait=100
DB1.MaxIdle=1
DB1.QueryListFile=./conf/query.props

#pay1
172.87.100.11.Url=jdbc:oracle:thin:@172.87.100.11:1521:pay1
172.87.100.11.User=zabbix_oracle_user
172.87.100.11.Password=zabbix_oracle_passwd
#
172.87.100.11.MaxActive=10
172.87.100.11.MaxWait=100
172.87.100.11.MaxIdle=1
172.87.100.11.QueryListFile=./conf/query.props

#pay2
172.87.100.12.Url=jdbc:oracle:thin:@172.87.100.12:1521:pay2
172.87.100.12.User=zabbix_oracle_user
172.87.100.12.Password=zabbix_oracle_passwd
#
172.87.100.12.MaxActive=10
172.87.100.12.MaxWait=100
172.87.100.12.MaxIdle=1
172.87.100.12.QueryListFile=./conf/query.props

配置完成後就可以啟動了

  /usr/local/orabbix/run.sh

  ps -ef | grep orabbix  //查看是否啟動成功

前端配置

  /usr/local/orabbix下面有個template目錄,裏面裝的是zabbix模板,將這些模板挪到本地機器上,然後登陸zabbix,把模板導入進去,就可以配置機器了。

zabbix3.4.6之監控Oracle