[Nagios-devel] Re: Bug: NSCA 2.4 on OS X 10.3

Ric Moseley ric at nkn.net
Wed Jan 28 15:15:53 CET 2004


Yeah, I also use printf.  Echo did not work as expected for me on FreeBSD.
Here is my config. 

/usr/bin/printf "%s\t%s\t$return_code\t%s\n" $1 "$2" "$4" |
/usr/local/nagios/sbin/nsca/send_nsca -H 192.168.1.2 -c /usr/local/nagi
os/sbin/nsca/send_nsca.cfg

Thanks.

Ric. 
The Planet
www.theplanet.com 

###### from: /usr/local/nagios/libexec/submit_check_result ####

#!/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

# 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$return_code\t%s\n" $1 "$2" "$4" |
/usr/local/nagios/sbin/nsca/send_nsca -H 192.168.1.2 -c /usr/local/nagi
os/sbin/nsca/send_nsca.cfg

########### from command.cfg ###############

define command{
        command_name    submit_check_result
        command_line    /usr/local/nagios/libexec/submit_check_result
$HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$OUTPUT$'
        }

-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Karl
DeBisschop
Sent: Wednesday, January 28, 2004 7:08 AM
To: Noah Leaman
Cc: Ethan Galstad; nagios devel; nagios-users at lists.sourceforge.net
Subject: [Nagios-users] Re: [Nagios-devel] Re: Bug: NSCA 2.4 on OS X 10.3

On Tue, 2004-01-27 at 22:59 -0800, Noah Leaman wrote:
> Yes. Look at that. It appears /bin/echo on OSX doesn't support -e ...

A note to developers. 'echo' is not portable. Use 'printf'

(See POSIX for a description of the rationale, but the long and short is
echo cannot be used portably.)

So the portable solution is like:

	printf "%s %s\n", $var1, $var2

-- 
Karl DeBisschop <kdebisschop at infoplease.com>
Director of Software Development, Infoplease/Pearson Education




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting
any issue. 
::: Messages without supporting info will risk being sent to /dev/null



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list