1.在數(shù)據(jù)庫(kù)上創(chuàng)建用戶(hù)并賦予權(quán)限(DBA配合操作;用戶(hù)、密碼待定;只是監(jiān)控本機(jī)數(shù)據(jù)庫(kù)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;
在福貢等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專(zhuān)注、極致的服務(wù)理念,為客戶(hù)提供網(wǎng)站設(shè)計(jì)、做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),營(yíng)銷(xiāo)型網(wǎng)站,外貿(mào)網(wǎng)站建設(shè),福貢網(wǎng)站建設(shè)費(fèi)用合理。
2.將nagios加入oinstall組
usermod -a -G oinstall nagios
二、查看被監(jiān)控是否安裝了perl?并且被監(jiān)控機(jī)安裝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.這里會(huì)碰到安裝錯(cuò)誤
切換到oracle用戶(hù):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環(huán)境
7.重新切回root:ctrl+d或su - root設(shè)置環(huán)境變量[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
四、測(cè)試
1.安裝完成后執(zhí)行命令:/usr/local/nagios/libexec/check_oracle_health --connect=oracle_SID --user=oracle用戶(hù) --password=oracle用戶(hù)密碼 --mode=connected-users
如果提示錯(cuò)誤:如
解決方法:
[root@D-MDB-90libexec]# ldd /usr/local/lib64/perl5/auto/DBD/Oracle/Oracle.so(安裝缺少文件路徑找)
發(fā)現(xiàn)沒(méi)有l(wèi)ibclntsh.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 的路徑有關(guān)
[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
結(jié)果輸出OK - connection established to pomoho.
3.修改/usr/local/nagios/etc/nrpe.cfg
在allowed_hosts后加上本機(jī)與監(jiān)控主機(jī)的IP
最后加一行command[check_oracle_health]=/usr/local/nagios/libexec/check_oracle_health --connect=oracle_SID --user=oracle用戶(hù) --password=oracle用戶(hù)密碼 --mode=tnsping
4.重啟nrpe
5./usr/local/nagios/libexec/check_nrpe -H你的被監(jiān)控機(jī)IP地址 -c check_oracle_health
如果結(jié)果同樣為OK - connectionestablished to pomoho,則OK
五、修改監(jiān)控主機(jī)的/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