Page 1 of 1

Nagios Bash plugin, one variable cant be parsed to nagios.

Posted: Fri Oct 17, 2014 2:38 am
by kratz
Hi!

I have a super simple plugin that executes a command on a remote windows server and checks that the output contains "Ja"

It looks like this:

Code: Select all

#!/bin/bash

RESULT=$(/usr/lib/nagios/plugins/check_nrpe -H $1 -c checksnap)
CROP=$(echo $RESULT | grep Status | cut -d' ' -f2)
POS=$(echo "Ja")

if [ ! -n "$1" ]
then
    echo "Du måste specifisera HOST"
    exit 3
fi

if [ $CROP=$POS ]; then
        SC="OK"
        EX=0
else
        SC="CRITICAL"
        EX=2
fi

echo "$SC $RESULT"
exit $EX
It works, and if I run it through bash at the server, the output looks like this:
OK Status: Ja 00:00:00.0781250
where SC=OK and RESULT=OK Status: Ja 00:00:00.0781250

But the variable RESULT never shows up as Status Information in Nagios!
If I create the variable like RESULT=$(echo "Status: Ja 00:00:00.0781250"), it obviously works.

Why does this happen?

Thanks
//Oscar

Re: Nagios Bash plugin, one variable cant be parsed to nagio

Posted: Fri Oct 17, 2014 9:20 am
by kratz
I sorted it out
Multiple problems including the script itself, and the "define command"

Re: Nagios Bash plugin, one variable cant be parsed to nagio

Posted: Fri Oct 17, 2014 9:48 am
by tmcdonald
Sorry we didn't get to you sooner - our support hours are 9AM to 5PM CDT so anything before or after those times will have a delay. I'll be closing this thread now, but feel free to open another if you need anything in the future!