Nagios監控Oracle(check_oracle_health)

來源:互聯網
上載者:User

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配置相同

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.