zabbix监控Oracle

安装zabbix agent

方法1

rpm包安装

redhat6

wget https://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-agent-3.4.9-1.el6.x86_64.rpm

rpm -ivhzabbix-agent-3.4.9-1.el6.x86_64.rpm

/etc/init.d/zabbix_agentd start

chkconfig --add zabbix_agentd

chkconfig --level 12345 zabbix_agentd on


redhat7

rpm -ihttps://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

rpm -ivhzabbix-release-3.4-2.el7.noarch.rpm

systemctl start zabbix_agentd

systemctl enable zabbix_agentd


yum方法网络安装

CentOS6

yum -y install zabbix-agentd

/etc/init.d/zabbix_agentd start

chkconfig --level 12345 zabbix_agentd on



CentOS7

yum -y install zabbix-agentd

systemctl start zabbix_agentd

systemctl enable zabbix_agentd


方法2

wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz

tar zxvf zabbix-3.4.12.tar.gz

ll

cd zabbix-3.4.12

ll

groupadd zabbix

useradd -g zabbix -s /sbin/nologin zabbix

./configure --prefix=/usr/local/zabbix-3.4.12--with-net-snmp --enable-agent


make

make install



cp misc/init.d/tru64/zabbix_agentd/etc/init.d/

chmod +x /etc/init.d/zabbix_agentd


vi /etc/init.d/zabbix_agentd


# chkconfig: 2345 10 90

# description: myservice ....


DAEMON=/usr/local/zabbix-3.4.12/sbin/zabbix_agentd


vim /usr/local/zabbix-3.4.12/etc/zabbix_agentd.conf

Server=172.16.80.222

ListenPort=10050

ServerActive=172.16.80.222

Hostname=Oracle1


/etc/init.d/zabbix_agentd start


chkconfig --add zabbix_agentd




注:libpcre是pcre-devel.x86_64的包含的文件。


安装配置orabbix


Oracle中创建监控用户并赋予权限

#su - oracle

#sqlplus /nolog

#conn /as sysdba

create user zabbixidentified by "zabbix" default tablespace users temporary tablespacetemp profile default account unlock;

grant alter session to zabbix;

grantcreate 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_historyto zabbix;

grant select on v_$parameterto zabbix;

grant select on sys.dba_audit_sessionto zabbix;

grant select on v_$lock tozabbix;

grant select on dba_registryto zabbix;

grant select onv_$librarycache to zabbix;

grant select on v_$sysstat tozabbix;

grant select on v_$parameterto zabbix;

grant select on v_$latch to zabbix;

grant select on v_$pgastat tozabbix;

grant select on v_$sgastat tozabbix;

grant select onv_$librarycache to zabbix;

grant select on v_$process tozabbix;

grant select on dba_data_filesto zabbix;

grant select on dba_temp_filesto zabbix;

grant select on dba_free_spaceto zabbix;

grant select onv_$system_event to zabbix;


grant select ondba_tablespaces to zabbix;

grant select on v_$session to zabbix;

grant select on dba_objects tozabbix;

grant select onv_$locked_object to zabbix;

grant select on v_$log tozabbix;


ACL:

begin

    dbms_network_acl_admin.create_acl(

    acl =>'UTL_INADDR.xml',

    description =>'utl_inaddr',

    principal => 'ZABBIX',

    is_grant => TRUE,

    privilege => 'resolve'

    );

    commit;

end;

/


begin

    dbms_network_acl_admin.add_privilege (

    acl => 'UTL_INADDR.xml',

    principal => 'ZABBIX',

    is_grant => TRUE,

    privilege => 'connect'

    );

    commit;

end;

/


begin

    dbms_network_acl_admin.assign_acl(

    acl => 'UTL_INADDR.xml',

    host => '*'

    );

    commit;

end;

/



Zabbix端需要做的配置

安装orabbix 


下载地址:http://www.smartmarmot.com/product/orabbix/download/

       1

)在/opt创建目录创建orabbix文件。(原因:orabbix启动文件默认写在/opt/orabbix目录下,也可以修改一下orabbix启动脚本的路径)          

#mkdir /opt/orabbix

#mv orabbix-1.2.3.zip /opt/orabbix

#cd /opt/orabbit

#unzip orabbix-1.2.3.zip

授予文件可执行的权限

#chmod a+x /opt/orabbix -R

创建一个名为config.props文件,有模板可以参考。

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


修改confi.props配置文件,仅需修改如下内容即可。

# cat /opt/orabbix/conf/config.props |grep-v "#"   这里仅取没有注释的。

ZabbixServerList=ZabbixServer          #zabbix名称


ZabbixServer.Address=192.168.0.119     #zabbix服务端的IP地址

ZabbixServer.Port=10051                #zabbix服务端的端口



OrabbixDaemon.PidFile=./logs/orabbix.pid

OrabbixDaemon.Sleep=300

OrabbixDaemon.MaxThreadNumber=100


DatabaseList=twstcptest.com    #这个名称可以随便起,但是必须跟监控的主机名保持一致。


DatabaseList.MaxActive=10

DatabaseList.MaxWait=100

DatabaseList.MaxIdle=1


twstcptest.com.Url=jdbc:oracle:thin:@192.168.0.110:1521:rdcms  #这里主要是通过JDBC来连接客户端的。rdcms主要是数据库的实例名称。在客户端可以通过select instance_name from v$instance来得到实例的名称。

twstcptest.com.User=zabbix      #数据库用户

twstcptest.com.Password=zabbix  #数据库用户密码

twstcptest.com.MaxActive=10

twstcptest.com.MaxWait=100

twstcptest.com.MaxIdle=1

twstcptest.com.QueryListFile=./conf/query.props






vi /opt/orabbix/conf/query.props


tbl_space.Query=SELECT * FROM ( \

select '- Tablespace ->',t.tablespace_namektablespace, \

      '- Type->',substr(t.contents, 1, 1) tipo, \

      '- Used(MB)->',trunc((d.tbs_size-nvl(s.free_space, 0))/1024/1024)ktbs_em_uso, \

      '- ActualSize(MB)->',trunc(d.tbs_size/1024/1024) ktbs_size, \

      '- MaxSize(MB)->',trunc(d.tbs_maxsize/1024/1024) ktbs_maxsize, \

      '- FreeSpace(MB)->',trunc(nvl(s.free_space, 0)/1024/1024)kfree_space, \

      '- Space->',trunc((d.tbs_maxsize - d.tbs_size + nvl(s.free_space,0))/1024/1024) kspace, \

      '- Perc->',decode(d.tbs_maxsize, 0, 0,trunc((d.tbs_size-nvl(s.free_space, 0))*100/d.tbs_maxsize)) kperc \

from \

  (select SUM(bytes) tbs_size, \

          SUM(decode(sign(maxbytes - bytes), -1, bytes, maxbytes)) tbs_maxsize,tablespace_name tablespace \

   from ( select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes,tablespace_name \

   from dba_data_files \

   union all \

   select nvl(bytes, 0) bytes, nvl(maxbytes, 0) maxbytes, tablespace_name \

   from dba_temp_files \

    )\

   group by tablespace_name \

    )d, \

    (select SUM(bytes) free_space, \

   tablespace_name tablespace \

   from dba_free_space \

   group by tablespace_name \

    )s, \

   dba_tablespaces t \

   where t.tablespace_name = d.tablespace(+) and \

   t.tablespace_name = s.tablespace(+) \

   order by 8) \

   where kperc >60 \

   and tipo <>'T' \

   and tipo <>'U'

如上修改kperc > 60,也就是使用率达到60%以上



参考:

https://www.cnblogs.com/zoulongbin/p/6395047.html

https://blog.csdn.net/ttt111zzz/article/details/79000411

https://blog.csdn.net/mchdba/article/details/51366790

http://www.cnblogs.com/leipei2352/archive/2011/06/14/2080575.html

https://www.linuxidc.com/Linux/2014-11/109776.htm

https://blog.csdn.net/mous3/article/details/50679256

你可能感兴趣的:(zabbix监控Oracle)