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

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
kratz
Posts: 2
Joined: Fri Oct 17, 2014 2:16 am

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

Post 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
kratz
Posts: 2
Joined: Fri Oct 17, 2014 2:16 am

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

Post by kratz »

I sorted it out
Multiple problems including the script itself, and the "define command"
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

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

Post 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!
Former Nagios employee
Locked