Penguin

Passive Service / Host Checks

Passive checks allow you to feed status information into Nagios at a time of your choosing rather than having Nagios continuously poll some device.

The typically way to implement them is using NSCA (Nagios Service Command Acceptor)

NSCA runs on the same server as Nagios and listens on a port to accept incoming results.

Example Nagios Passive service template

# APC UPS Passive Check
define service {
        use                             generic-service
        name                            g-apc-ups

        service_description             APC UPS Power
        max_check_attempts              1
        normal_check_interval           5
        retry_check_interval            1
        notification_interval           30
        notification_period             24x7
        notification_options            u,w,c,r

contact_groups                  admin-lists

        flap_detection_enabled          0
        active_checks_enabled           0
        check_command                   check_ping

        register                        0
}
# Machines connected to an APC ups
define service {
        use                     g-apc-ups
        hostgroup_name          ups_servers
}

Example NSCA config

####################################################
# NSCA Daemon Config File
# Last Modified: 25 Feb 2005
####################################################

# PORT NUMBER
server_port=5667

# ALLOWED HOST ADDRESSES
allowed_hosts=192.168.70.10,192.168.70.234
# Plaintext passwords!
password=your-password
decryption_method=1

nsca_user=nagios
nsca_group=nagios
debug=0
command_file=/var/log/nagios/rw/nagios.cmd
alternate_dump_file=/var/log/nagios/rw/nsca.dump
aggregate_writes=0
append_to_file=0
max_packet_age=30

Example to generate a passive event

#!/bin/bash
#
# Setup some defaults to be used by the notification scripts

HOSTNAME=`hostname`
NAGIOS_HOST="x.x.x.x"
NSCA_CONFIG="/etc/nsca.conf"
SERVICE="APC UPS Power"

send_alert() {

        echo "$HOSTNAME    $SERVICE        $1      $2
" | /usr/bin/send_nsca -H $NAGIOS_HOST -c $NSCA_CONFIG &>/dev/null

}

Source the above script and then call send_alert "0" "Status Msg here"

  • 0 == OK
  • 1 = WARNING
  • 2 = CRITICAL