return code lost during sending check result
Jakub Safar
safarj at kancelarskestroje.cz
Wed Sep 21 22:13:42 CEST 2005
Marc, thank you! Done&Works. Im sorry ... Ich bin ein Nagios newbie.
Jakub
p.s. here are those working files:
define command{
command_name submit_check_result
command_line /usr/lib/nagios/plugins/eventhandlers/distributed-monitoring/submit_check_result_via_nsca $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$' "misccommands.cfg"
submit_check_result_via_nsca:
case "$3" in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
printfcmd="/usr/bin/printf"
NscaBin="/usr/sbin/send_nsca"
NscaCfg="/etc/nagios/send_nsca.cfg"
NagiosHost="XXX.XXX.XXX.XXX"
$printfcmd "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | $NscaBin
$NagiosHost -c $NscaCfg
keywords: nagios, passive, nsca, ok, service, host, status, critical .
On Wed, 2005-09-21 at 11:47 -0500, Marc Powell wrote:
>
> > -----Original Message-----
> > From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> > admin at lists.sourceforge.net] On Behalf Of Jakub Safar
> > Sent: Wednesday, September 21, 2005 10:09 AM
> > To: nagios-users
> > Subject: [Nagios-users] return code lost during sending check result
> >
> > Hello,
> >
> > exit return codes of check_ping is lost by Nagios while sending
> results
> > through NSCA to other Nagios server.
> >
> > Command "submit_check_result" is defined like this:
> > submit_check_result_via_nsca $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$
> > '$OUTPUT$'
> >
> > submit_check_result_via_nsca includes:
> > cmdline="$1;$2;$3;$4"
> > $echocmd "$1\t$2\t$3\t$4\n" | $NscaBin $NagiosHost -p $NagiosHostPort
> -c
> > $NscaCfg
> >
>
> If $3 == $SERVICESTATE$ you need to do some additional processing as
> nsca/nagios on the far side are expecting a numerical value. You'll need
> to translate $SERVICESTATE$ into the proper exit code before passing it
> on to NSCA. See the example submit_check_result code at
> http://nagios.sourceforge.net/docs/1_0/distributed.html and verify that
> your script performs that translation.
>
> Additionally, verify that the SERVICESTATE variable is being passed to
> submit_check_result properly. It's very likely that it is but to be on
> the safe side, try echoing the cmdline to a tmp file somewhere and make
> sure that $3 == CRITICAL or OK or whatever the state is before the
> translation.
>
> --
> Marc
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server.
> Download it for free - -and be entered to win a 42" plasma tv or your very
> own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> 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
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
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