zabbix3.4.6之监控Oracle

  新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 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=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

PS:

  需要注意的是DatabaseList=DB1指的是被监控服务器的名称,该名称要和zabbix server界面中的机器名称保持一致,该配置文件中后续所引用的设定都以该名称为准。

  DB1.Url=jdbc:oracle:thin:@172.87.100.11:1521:pay1指定的是被监控服务器的连接信息(例如采用jdbc的联接方式,服务器地址是172.87.100.11,oracle的端口是1521,pay1指的是数据库的实例名称。

配置完成后就可以启动了

  /usr/local/orabbix/run.sh

  ps -ef | grep orabbix  //查看是否启动成功

前端配置

  /usr/local/orabbix下面有个template目录,里面装的是zabbix模板,将这些模板copy到本地机器上,然后登陆zabbix,把模板导入进去,就可以配置机器了。

posted @ 2018-04-28 11:55  houyongchong  阅读(3418)  评论(0编辑  收藏  举报