您好,登錄后才能下訂單哦!
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
wget http://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]#export ORACLE_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]# wget https://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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。