check_oracle_health监控oracle-创新互联
一、准备工作
1.在数据库上创建用户并赋予权限(DBA配合操作;用户、密码待定;只是监控本机数据库TNS、SID)
CREATE USER nagios IDENTIFIED BY XXXX;
GRANT CREATE SESSIONTO nagios;
GRANT SELECT anydictionary TO nagios;
GRANT SELECT ONV_$SYSSTAT TO nagios;
GRANT SELECT ONV_$INSTANCE TO nagios;
GRANT SELECT ON V_$LOGTO nagios;
GRANT SELECT ONSYS.DBA_DATA_FILES TO nagios;
GRANT SELECT ONSYS.DBA_FREE_SPACE TO nagios;
GRANT SELECT ONsys.dba_tablespaces TO nagios;
GRANT SELECT ONdba_temp_files TO nagios;
GRANT SELECT ONsys.v_$Temp_extent_pool TO nagios;
GRANT SELECT ONsys.v_$TEMP_SPACE_HEADER TO nagios;
GRANT SELECT ONsys.v_$session TO nagios;
2.将nagios加入oinstall组
usermod -a -G oinstall nagios
二、查看被监控是否安装了perl?并且被监控机安装DBI和DBD
1.[root@D-MDB-90 ~]# perl -v
This is perl, v5.10.1 (*) built forx86_64-linux-thread-multi
Copyright 1987-2009, Larry Wall
Perl may be copied only under theterms of either the Artistic License or the
GNU General Public License, which maybe found in the Perl 5 source kit.
Complete documentation for Perl,including FAQ lists, should be found on
this system using "manperl" or "perldoc perl". If you have access to the
Internet, point your browser athttp://www.perl.org/, the Perl Home Page.
2.下载DBI
wgethttp://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.636.tar.gz
3.解压DBI
[root@D-MDB-90 src]#tar zxvf DBI-1.636.tar.gz
4.安装DBI
[root@D-MDB-90 src]# cd DBI-1.636
[root@D-MDB-90 DBI-1.636]# perlMakefile.PL
[root@D-MDB-90 DBI-1.636]# make all
[root@D-MDB-90 DBI-1.636]# make install
5.下载安装DBD-Oracle
[root@D-MDB-90 src]# wget http://mirrors.neusoft.edu.cn/cpan/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.74.tar.gz
[root@D-MDB-90 src]# tar zxvf DBD-Oracle-1.74.tar.gz
[root@D-MDB-90 src]# cd DBD-Oracle-1.74
[root@D-MDB-90DBD-Oracle-1.74]# perl Makefile.PL
6.这里会碰到安装错误
切换到oracle用户:su - oracle
查看ORACLE_HOME路径:echo $ORACLE_HOME
[root@D-MDB-90libexec]# echo $ORACLE_HOME /oracle/app/oracle/products/11.2.0.3/db #记住这条oracle_home环境
7.重新切回root:ctrl+d或su - root设置环境变量[root@D-MDB-90DBD-Oracle-1.74]#exportORACLE_HOME=/oracle/app/oracle/products/11.2.0.3/db
[root@D-MDB-90 DBD-Oracle-1.74]#perl Makefile.PL
[root@D-MDB-90DBD-Oracle-1.74]#make && make install
三、下载安装check_oracle_health
1.[root@D-MDB-90 src]# wgethttps://labs.consol.de/assets/downloads/nagios/check_oracle_health-2.1.3.5.tar.gz
2.[root@D-MDB-90 src]# tar -zxvfcheck_oracle_health-2.1.3.5.tar.gz
3.[root@D-MDB-90 src]#cd check_oracle_health-2.1.3.5
4. ./configure --prefix=/usr/local/nagios--with-nagios-user=nagios --with-nagios-group=nagios--with-mymodules-dir=/usr/local/nagios/libexec --with-mymodules-dyndir=/usr/local/nagios/libexec
5. [root@D-MDB-90 src]make all
6.[root@D-MDB-90 src]make install
7.chown nagios:nagios/usr/local/nagios/libexec/check_oracle_health
8.chmod 775/usr/local/nagios/libexec/check_oracle_health
四、测试
1.安装完成后执行命令:/usr/local/nagios/libexec/check_oracle_health --connect=oracle_SID --user=oracle用户 --password=oracle用户密码 --mode=connected-users
如果提示错误:如
解决方法:
[root@D-MDB-90libexec]# ldd /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so(安装缺少文件路径找)
发现没有libclntsh.so.11.1
[root@D-MDB-90libexec]# locate libclntsh.so.11.1
[root@D-MDB-90 libexec]# ln -s /oracle/app/oracle/products/11.2.0.3/db/lib/libclntsh.so.11.1(空格)/lib/libclntsh.so.11.1
[root@D-MDB-90 libexec]# vim /etc/ld.so.conf
添加
include ld.so.conf.d/*.conf
/oracle/app/oracle/products/11.2.0.3/db/lib #这里的路径与libclntsh.so.11.1 的路径有关
[root@D-MDB-90 libexec]# ldconfig
[root@D-MDB-90 libexec]# ldd/usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so
2.[root@D-MDB-90 libexec]#/usr/local/nagios/libexec/check_oracle_health --connect=pomoho --user=nagios --password=oradbmon --mode=tnsping
结果输出OK - connection established to pomoho.
3.修改/usr/local/nagios/etc/nrpe.cfg
在allowed_hosts后加上本机与监控主机的IP
最后加一行command[check_oracle_health]=/usr/local/nagios/libexec/check_oracle_health --connect=oracle_SID --user=oracle用户 --password=oracle用户密码 --mode=tnsping
4.重启nrpe
5./usr/local/nagios/libexec/check_nrpe -H你的被监控机IP地址 -c check_oracle_health
如果结果同样为OK - connectionestablished to pomoho,则OK
五、修改监控主机的/usr/local/nagios/etc/objects/services.cfg
添加
###################XX-XXX-XXcheck_oracle_health#####################################
define service{
host_name XX-XXX-XX
service_description check_oracle_health_tnsping
check_command check_nrpe!check_oracle_health
max_check_attempts 5
normal_check_interval 5
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups yunwei
}
检查配置是否正确 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
重新加载nagios : service nagios reload
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站名称:check_oracle_health监控oracle-创新互联
标题网址:http://ybzwz.com/article/dsggdc.html