Nagios监控Oracle(check_oracle_health)


Nagios自带的Oracle监控check_oracle功能较少,可以采用perl写的check_oracle_health脚本

1、安装check_oracle_health

wget http://www.bkjia.com/system/systembak/2011/2/check_oracle_health-1.6.6.1.tar.gz

wget http://www.bkjia.com/system/systembak/2011/2/check_oracle_health-1.6.3.tar.gz

版本任意选(此处使用1.6.3)

tar zxvf check_oracle_health-1.6.3.tar.gz

cd check_oracle_health-1.6.3
./configure --prefix=/usr/local/nagios/ --with-nagios-user=nagios --with-nagios-gourp=nagios --with-mymodules-dir=/usr/local/nagios/libexec/ --with-mymodules-dyn-dir=/usr/local/nagios/libexec/

#指定用户、用户组以及目标路径等
make all

make install

2、设定系统环境变量

root下,编辑.bash_profile,插入oracle用户的环境变量,要和oracle用户的.bash_profile文件中设置的一样

export PATH
unset USERNAME
PS1="\[\e[0m\][\u@\[\e[32;1m\]`/sbin/ifconfig eth0 | grep "inet addr" | sed -e "s/^.*inet addr:\(.*\) Bcast.*$/\1/"`\[\e[0m\]\W]# "
export PS1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.1/db
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=qiyue
                          

3、安装perl的oracle插件

① wget http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.609.tar.gz

    tar zxvf DBI-1.609.tar.gz

    cd DBI-1.609

    perl Makefile.PL
    make all 

    make install
② wget  http://cpan.wenzk.com/authors/id/P/PY/PYTHIAN/DBD-Oracle-1.24a.tar.gz

    tar -zxvf DBD-Oracle-1.24a.tar.gz 
    cd DBD-Oracle-1.24
    perl Makefile.PL             #此处如果之前不设定root的oracle环境变量会报错

    make all

    make install

③ 如果在运行脚本时报错

    Can't locate Time/HiRes.pm in @INC (@INC contains: /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi
    wget http://www.perl.com/CPAN/modules/by-module/Time/Time-HiRes-01.02.tar.gz
    tar zxvf Time-HiRes-01.02.tar.gz

    cd Time-HiRes-01.02
    perl Makefile.PL
    make all
    make install

4、测试

cd /usr/local/nagios/libexec

 ./check_oracle_health --connect=nagios --username system --password ora123 --mode connected-users
OK - 11 connected users | connected_users=11;50;100

‍./check_oracle_health --connect=nagios --username system --password ora123 --mode=tnsping
OK - connection established to nagios.

5、其余配置和nagios配置相同

相关内容