Passive Überwachung

Aus MeinWiki
Wechseln zu: Navigation, Suche

Die passive Überwachung erfolg über NSCA.

Konfiguration Nagios-Host

  • Command definieren. (commands.cfg)
define command{
        command_name    check_dummy
        command_line    $USER1$/check_dummy $ARG1$
}
  • Service Template erstellen. (service_templates.cfg)
define service{
    use                     generic-service   ; template to inherit from
    name                    passive-service   ; name of this template
    active_checks_enabled   0                 ; no active checks
    passive_checks_enabled  1                 ; allow passive checks
    check_command           check_dummy!0     ; use "check_dummy", RC=0 (OK)
    check_period            24x7              ; check active all the time
    check_freshness         0                 ; don't check if check result is "stale"
    register                0                 ; this is a template, not a real service
}
  • Check konfigurieren. (services.cfg)
define service{
   use                     passive-service   ; template to inherit from
   host_name               shel-db1        ; host where send_nsca is located
   service_description     TABLESPACE-USERS  ; service to be checked
}

Konfiguration Client

  • nagios-plugin installierten.
  • Script anpassen.
#!/bin/bash

# cron
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/10.2/db_1
export ORACLE_SID=heldb

# PARAMETER
hostName='shel-db1'             #Nagiosconfig

SetReturnCode()
{
   # $1 Hostname
   # $2 NSA Name
   # $3 Return Check
   funcReturn=3
   if [ $# -eq 3 ]; then
       case "$3" in
       *OK*)
          funcReturn=$1";"$2"; 0; "$3
          ;;
       *WARNING*)
          funcReturn=$1";"$2"; 1; "$3
          ;;
       *CRITICAL*)
          funcReturn=$1";"$2"; 2; "$3
          ;;
       *)
          funcReturn=$1";"$2"; 3; "$3
          ;;
       esac
   fi
   echo $funcReturn
}

SendNagios()
{
  if [ $# -eq 1 ]; then
       /bin/echo $1 |LD_PRELOAD=/usr/local/nagios/nsca/libmcrypt.so.4 /usr/local/nagios/nsca/send_nsca -H 172.16.2.106 -d ';' -c /usr/local/nagios/nsca/send_nsca.cfg
  fi
}

#MAIN
SendNagios "$(SetReturnCode $hostName 'Diskspace' "`/usr/local/nagios/libexec/check_disk -w 5% -c 2% -M /`")"
SendNagios "$(SetReturnCode $hostName 'TABLESPACE-USERS' "`/usr/local/nagios/libexec/custom/check_oracle_health --connect shel-db1 --user nagios --password 2008nag! --warning 80 --critical 90 --mode tablespace-usage -name USERS`")"
  • Cronjob einrichten.
*/5  *  *  *  * /usr/local/nagios/script/check.sh