Package: nagios-common
Version: 2:1.3-cvs.20050402-2.sarge.1
Severity: wishlist
Tags: patch

Hello,

I have a nagios server that displays information gathered and forwarded
from a second nagios server in a private subnet.  The one in the private
subnet uses send_nsca and the example script in
/usr/lib/nagios/plugins/eventhandlers/distributed-monitoring/submit_check_result_via_nsca
to send the results.

Unfortunately, this was resulting in all services and hosts being in the
OK state, even though the plugin output showed "timed out" or
"connection refused".  The prolem, it turns out, is that the
user-friendly WARNING/OK/etc messages need to be translated into a
numeric code so that nagios sees the actual status of the service.

A better sample is below:

--------------------------------------------------------------

#!/bin/sh

# Arguments:
#  $1 = host_name (Short name of host that the service is
#       associated with)
#  $2 = svc_description (Description of the service)
#  $3 = state_string (A string representing the status of
#       the given service - "OK", "WARNING", "CRITICAL"
#       or "UNKNOWN")
#  $4 = plugin_output (A text string that should be used
#       as the plugin output for the service checks)
#

# Convert the state string to the corresponding return code
return_code=-1

case "$3" in
        OK)
                return_code=0
                ;;
        WARNING)
                return_code=1
                ;;
        CRITICAL)
                return_code=2
                ;;
        UNKNOWN)
                return_code=-1
                ;;
esac

nagios_host='my.nagios.host.tld'

# pipe the service check info into the send_nsca program, which
# in turn transmits the data to the nsca daemon on the central
# monitoring server

/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | 
/usr/sbin/send_nsca -c /etc/send_nsca.cfg -H $nagios_host

-------------------------------------------------------------------

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.10-1-686-smp
Locale: LANG=C, LC_CTYPE=en_US.ISO-8859-15 (charmap=ISO-8859-15) (ignored: 
LC_ALL set to en_US.ISO-8859-15)

Versions of packages nagios-common depends on:
ii  adduser     3.63                         Add and remove users and groups
ii  apache [htt 1.3.33-6                     versatile, high-performance HTTP s
ii  coreutils [ 5.2.1-2                      The GNU core utilities
ii  debconf [de 1.4.51                       Debian configuration management sy
ii  mailx       1:8.1.2-0.20040524cvs-4      A simple mail user agent
ii  nagios-plug 1.4-6                        Plugins for the nagios network mon
ii  nagios-text 2:1.3-cvs.20050402-2.sarge.1 A host/service/network monitoring 

-- debconf information:
* nagios/wwwsuid: true
  nagios/upgradefromnetsaint:
* nagios/configapache: Apache

-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        [EMAIL PROTECTED] |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

Attachment: signature.asc
Description: Digital signature

Reply via email to