设为首页 收藏本站
查看: 629|回复: 0

Oracle Database 监控(check_oracle_health)

[复制链接]

尚未签到

发表于 2019-1-12 11:15:32 | 显示全部楼层 |阅读模式
[oracle@amb01 ~]$ sqlplus / as sysdba
SQL> create user nagios identified by nagios;
User created.
SQL> grant dba to nagios;
Grant succeeded.
[root@nagios ~]# yum install -y libaio libaio-devel
[root@nagios ~]# groupadd oinstall
[root@nagios ~]# useradd -g oinstall oracle
[root@nagios ~]# echo oracle | passwd --stdin oracle
[root@nagios ~]# id oracle
uid=501(oracle) gid=503(oinstall) groups=503(oinstall)
[root@nagios ~]# mkdir -p /u01/app/oracle
[root@nagios ~]# chown -R oracle:oinstall /u01/app
[root@nagios ~]# chmod -R 775 /u01/app
[root@nagios ~]# su - oracle
[oracle@nagios ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/client
export PATH=$ORACLE_HOME/bin:$PATH
export DISPLAY=192.168.1.99:0
export NLS_LANG=AMERICAN_AMERICA.UTF8
export NLS_DATE_FORMAT="yyyy-mm-dd hh24:mi:ss"
stty erase ^H
[oracle@nagios ~]$ source .bash_profile
[oracle@nagios ~]$ unzip p13390677_112040_Linux-x86-64_4of7.zip
[oracle@nagios ~]$ cd client
[oracle@nagios client]$ ./runInstaller
[root@nagios ~]# /u01/app/oraInventory/orainstRoot.sh
[root@nagios ~]# vi /etc/ld.so.conf
/u01/app/oracle/product/11.2.0/client/lib
[root@nagios ~]# ldconfig
[root@nagios ~]# yum -y install perl-ExtUtils-MakeMaker perl-Time-HiRes
[root@nagios ~]# tar zxvf DBI-1.637.tar.gz
[root@nagios ~]# cd DBI-1.637
[root@nagios DBI-1.637]# perl Makefile.PL
[root@nagios DBI-1.637]# make all
[root@nagios DBI-1.637]# make install
[root@nagios ~]# export ORACLE_HOME=/u01/app/oracle/product/11.2.0/client
[root@nagios ~]# tar zxvf DBD-Oracle-1.74.tar.gz
[root@nagios ~]# cd DBD-Oracle-1.74
[root@nagios DBD-Oracle-1.74]# perl Makefile.PL
[root@nagios DBD-Oracle-1.74]# make all
[root@nagios DBD-Oracle-1.74]# make install
[root@nagios ~]# tar zxvf check_oracle_health-3.1.2.2.tar.gz
[root@nagios ~]# cd check_oracle_health-3.1.2.2
[root@nagios check_oracle_health-3.1.2.2]# ./configure --prefix=/usr/local/icinga \
--with-nagios-user=icinga \
--with-nagios-group=icinga \
--with-mymodules-dir=/usr/local/icinga/libexec
[root@nagios check_oracle_health--3.1.2.2]# make all
[root@nagios check_oracle_health--3.1.2.2]# make install
[root@nagios ~]# su - oracle
[oracle@nagios ~]$ cd /u01/app/oracle/product/11.2.0/db_1/network/admin/
[oracle@nagios admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
AMBDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ambdb)
    )
  )
[oracle@nagios ~]$ tnsping ambdb
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 06-AUG-2018 14:00:26
Copyright (c) 1997, 2013, Oracle.  All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ambdb)))
OK (0 msec)
[root@nagios ~]# cd /usr/local/icinga/libexec/
[root@nagios libexec]# vi check_oracle_health
$ENV{"ORACLE_HOME"} = "/u01/app/oracle/product/11.2.0/client";
[root@nagios libexec]# ./check_oracle_health
Please select a mode
Copyright (c) 2008 Gerhard Lausser

  Check various parameters of Oracle databases
  Usage:
    check_oracle_health [-v] [-t ] --connect=
        --username= --password= --mode=
        --tablespace=
    check_oracle_health [-h | --help]
    check_oracle_health [-V | --version]
  Options:
    --connect
       the connect string
    --username
       the oracle user
    --password
       the oracle user's password
    --warning
       the warning range
    --critical
       the critical range
    --mode
       the mode of the plugin. select one of the following keywords:
       tnsping                          (Check the reachability of the server)
       connection-time                  (Time to connect to the server)
       password-expiration              (Check the password expiry date for users)
       connected-users                  (Number of currently connected users)
       session-usage                    (Percentage of sessions used)
       process-usage                    (Percentage of processes used)
       rman-backup-problems             (Number of rman backup errors during the last 3 days)
       sga-data-buffer-hit-ratio        (Data Buffer Cache Hit Ratio)
       sga-library-cache-gethit-ratio   (Library Cache (Get) Hit Ratio)
       sga-library-cache-pinhit-ratio   (Library Cache (Pin) Hit Ratio)
       sga-library-cache-reloads        (Library Cache Reload (and Invalidation) Rate)
       sga-dictionary-cache-hit-ratio   (Dictionary Cache Hit Ratio)
       sga-latches-hit-ratio            (Latches Hit Ratio)
       sga-shared-pool-reload-ratio     (Shared Pool Reloads vs. Pins)
       sga-shared-pool-free             (Shared Pool Free Memory)
       pga-in-memory-sort-ratio         (PGA in-memory sort ratio)
       invalid-objects                  (Number of invalid objects in database)
       stale-statistics                 (Find objects with stale optimizer statistics)
       corrupted-blocks                 (Number of corrupted blocks in database)
       tablespace-usage                 (Used space in tablespaces)
       tablespace-free                  (Free space in tablespaces)
       container-tablespace-free        (Free space in tablespaces of container databases)
       tablespace-remaining-time        (Remaining time until a tablespace is full)
       tablespace-fragmentation         (Free space fragmentation index)
       tablespace-io-balance            (balanced io of all datafiles)
       tablespace-can-allocate-next     (Segments (of a tablespace) can allocate next extent)
       datafile-io-traffic              (io operations/per sec of a datafile)
       datafiles-existing               (Percentage of the maximum possible number of datafiles)
       datafiles-recovery               (Check if datafiles need media recovery)
       datafiles-offline                (Check if datafiles are offline)
       asm-diskgroup-usage              (Used space in diskgroups)
       asm-diskgroup-free               (Free space in diskgroups)
       soft-parse-ratio                 (Percentage of soft parses)
       switch-interval                  (Time between redo log file switches)
       retry-ratio                      (Redo buffer allocation retries)
       redo-io-traffic                  (Redo log io bytes per second)
       roll-header-contention           (Rollback segment header contention)
       roll-block-contention            (Rollback segment block contention)
       roll-hit-ratio                   (Rollback segment hit ratio (gets/waits))
       roll-wraps                       (Rollback segment wraps (per sec))
       roll-extends                     (Rollback segment extends (per sec))
       roll-avgactivesize               (Rollback segment average active size)
       seg-top10-logical-reads          (user objects among top 10 logical reads)
       seg-top10-physical-reads         (user objects among top 10 physical reads)
       seg-top10-buffer-busy-waits      (user objects among top 10 buffer busy waits)
       seg-top10-row-lock-waits         (user objects among top 10 row lock waits)
       event-waits                      (processes wait events)
       event-waiting                    (time spent by processes waiting for an event)
       enqueue-contention               (percentage of enqueue requests which must wait)
       enqueue-waiting                  (percentage of time spent waiting for the enqueue)
       latch-contention                 (percentage of latch get requests which must wait)
       latch-waiting                    (percentage of time a latch spends sleeping)
       sysstat                          (change of sysstat values over time)
       dataguard-lag                    (Dataguard standby lag)
       dataguard-mrp-status             (Dataguard standby MRP status)
       flash-recovery-area-usage        (Used space in flash recovery area)
       flash-recovery-area-free         (Free space in flash recovery area)
       failed-jobs                      (The jobs which did not exit successful in the last  minutes (use --lookback))
       sql                              (any sql command returning a single number)
       sql-runtime                      (the time an sql command needs to run)
       list-tablespaces                 (convenience function which lists all tablespaces)
       container-list-tablespaces       (convenience function which lists all tablespaces of all container databases)
       list-datafiles                   (convenience function which lists all datafiles)
       list-asm-diskgroups              (convenience function which lists all asm diskgroups)
       list-enqueues                    (convenience function which lists all enqueues)
       list-latches                     (convenience function which lists all latches)
       list-events                      (convenience function which lists all events)
       list-background-events           (convenience function which lists all background events)
       list-sysstats                    (convenience function which lists all statistics from v$sysstat)
[root@nagios libexec]# ./check_oracle_health --connect=ambdb --username=nagios --password=nagios --mode=tnsping
OK - connection established to zxmdb.
[root@nagios libexec]# ./check_oracle_health --connect=ambdb --username=nagios --password=nagios --mode=connection-time
OK - 0.06 seconds to connect as NAGIOS | connection_time=0.0598;1;5

[root@nagios ~]# cd /usr/local/icinga/etc/objects/
[root@nagios objects]# vi commands.cfg
define command{
        command_name    check_oracle
        command_line    $USER1$/check_oracle_health --connect=$ARG1$ --username=nagios --password=nagios --mode=$ARG2$
        }
[root@nagios objects]# vi oracle.cfg  
# define a host
define host{
        use                     linux-server
        host_name               ambdb
        alias                   ambdb
        icon_image              redhat.gif
        statusmap_image         redhat.gd2
        address                 192.168.1.202
        }
# define an hostgroup
define hostgroup{
        hostgroup_name  sale-oracle
        alias           database
        members         ambdb
        }
# define an servicegroup
define servicegroup {
        servicegroup_name  oracle
        alias  database
}

# Define a service
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             alive
        servicegroups                   ping
        check_command                   check_ping!100.0,20%!500.0,60%
        }
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             os cpu usage
        servicegroups                   os
        check_command                   check_nrpe!check_cpu
        }
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             os memory usage
        servicegroups                   os
        check_command                   check_nrpe!check_memory
        }
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             os disk usage
        servicegroups                   os
        check_command                   check_nrpe!check_disk
        }
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             os network usage
        servicegroups                   os
        check_command                   check_nrpe!check_network
        }
define service{
        hostgroup_name                  sale-oracle
        use                             generic-service
        service_description             os uptime
        servicegroups                   os
        check_command                   check_nrpe!check_uptime
        }
define service{
        host_name                       ambdb
        use                             generic-service
        service_description             oracle tnsping
        servicegroups                   oracle
        check_command                   check_oracle!zxmdb!tnsping
        }
define service{
        host_name                       ambdb
        use                             generic-service
        service_description             oracle connection-time
        servicegroups                   oracle
        check_command                   check_oracle!zxmdb!connection-time
        }
[root@nagios ~]# cd /usr/local/icinga/etc        
[root@nagios etc]# vi icinga.cfg
cfg_file=/usr/local/icinga/etc/objects/oracle.cfg
[root@nagios objects]# service icinga restart
Running configuration check...OK
Stopping Icinga: Waiting for icinga to exit ..Stopping icinga done.
Starting icinga: Starting icinga done.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662316-1-1.html 上篇帖子: nagios安装的配置笔记 下篇帖子: 数据库监控:nagios(check_mysql_health)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表