Oracle Database 監控(check_oracle_health)

[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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章