使用nagios监控oracle服务

配置 Nagios 监控 Oracle 服务器
环境:Oracle 10g
CentOS 5.4

一、在 Oracle 所在服务器上安装 NRPE
1.安装过程参考 Nagios NRPE 文档。

[root@ora etc]# grep -v "#" nrpe.cfg

log_facility=daemon

pid_file=/var/run/nrpe.pid

server_port=5666

nrpe_user=nagios

nrpe_group=nagios

allowed_hosts=192.168.0.200
dont_blame_nrpe=0
debug=0

command_timeout=60

connection_timeout=300

2.给 oracle 用户在 ORACLE_HOME 目录下执行权限。

[oracle@ora ~]$ chmod -Rf 740 ${ORACLE_HOME}

3.修改 check_oracle 脚本。将 $ORACLE_HOME 以及 $PATH 手动加入,避免出现问题。

[oracle@ora ~]$ echo ${ORACLE_HOME}
/u01/oracle/database/10.2.0/db_1

[oracle@ora ~]$ echo ${PATH}
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/u01/oracle/bin:/u01/oracle/database/10.2.0/

db_1/bin:.

这么做是为了确保脚本可以正常执行 sqlplus 以及 tnsping 等命令

二、配置 nrpe 服务

在nrpe.conf文件末尾加入如下内容

#Check Oracle
command[check_oracle_tns]=/usr/local/nagios/libexec/check_oracle --tns orcl
command[check_oracle_db]=/usr/local/nagios/libexec/check_oracle --db orcl
command[check_oracle_login]=/usr/local/nagios/libexec/check_oracle --login orclc
command[check_oracle_tablespace]=/usr/local/nagios/libexec/check_oracle --tables
pace orcl system lkjsdf tab 90 80

具体参数写法请参考 check_oracle --help

重启nrpe进程

[root@ora etc]# killall nrpe
[root@ora etc]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg �Cd

三、配置 Nagios 服务端

在 nagios/etc/objects 添加oracle 主机配置文件,orac.cfg。

44 #add oracle database moniter service by jadeshow
45 define service {
46                  use             generic-service
47                 host_name       database
48                 service_description     TNS Check
49                 check_command   check_nrpe!check_oracle_tns
50                 }
51 define service {
52                 use             generic-service
53                 host_name       database
54                 service_description     DB Check
55                 check_command   check_nrpe!check_oracle_db
56                 }
57
58 define service {
59                 use             generic-service
60                 host_name       database
61                 service_description     Login Check
62                 check_command   check_nrpe!check_oracle_login
63                 }
64
65
66 define service {
67                 use             generic-service
68                 host_name       database
69                 service_description     Tablespace Check
70                 check_command   check_nrpe!check_oracle_tablespace
71                 }

4.验证配置文件无误后重启 nagios 服务

[root@june objects]# nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios 3.1.0
Copyright (c) 1999-2009 Ethan Galstad (http://www.nagios.org)
Last Modified: 01-25-2009
License: GPL

Reading configuration data...
   Read main config file okay...
Processing object config file '/usr/local/nagios//etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/test.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/server1.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/server2.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/orac.cfg'...
Processing object config file '/usr/local/nagios//etc/objects/localhost.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
        Checked 38 services.
Checking hosts...
        Checked 5 hosts.
Checking host groups...
        Checked 2 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 1 contacts.
Checking contact groups...
        Checked 1 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 25 commands.
Checking time periods...
        Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
[root@june objects]#

5.重新启动nagios服务

[root@june objects]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.
[root@june objects]#

四、验证nagios的oracle服务

oracle数据库监控如图

image

 

多吃东西多喝水,

少玩游戏少睡觉! -------

望月飞鱼(珏石头)

你可能感兴趣的:(oracle,服务器,监控,nagios,休闲)