[Pkg-nagios-devel] Bug#314371: nagios-common: Provided send_nsca script is wrong

Stephen Gran Stephen Gran <sgran@debian.org>, 314371@bugs.debian.org
Wed, 15 Jun 2005 18:58:38 -0400


--y0ulUmNC+osPPQO6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
=66rom 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_r=
esult_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 =3D host_name (Short name of host that the service is
#       associated with)
#  $2 =3D svc_description (Description of the service)
#  $3 =3D state_string (A string representing the status of
#       the given service - "OK", "WARNING", "CRITICAL"
#       or "UNKNOWN")
#  $4 =3D 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=3D-1

case "$3" in
        OK)
                return_code=3D0
                ;;
        WARNING)
                return_code=3D1
                ;;
        CRITICAL)
                return_code=3D2
                ;;
        UNKNOWN)
                return_code=3D-1
                ;;
esac

nagios_host=3D'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/sbi=
n/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=3DC, LC_CTYPE=3Den_US.ISO-8859-15 (charmap=3DISO-8859-15) (ign=
ored: 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 HT=
TP s
ii  coreutils [ 5.2.1-2                      The GNU core utilities
ii  debconf [de 1.4.51                       Debian configuration managemen=
t 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 monitor=
ing=20

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

--=20
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        sgran@debian.org |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

--y0ulUmNC+osPPQO6
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCsLKeSYIMHOpZA44RAmTCAKCsw4TxIS64U0arJzIP/G5eWsuGNACgzNtv
OfJgso+UJwhdouuiHRrzPE0=
=bNVX
-----END PGP SIGNATURE-----

--y0ulUmNC+osPPQO6--