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
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款