Page 1 of 2

Service returning longoutput

Posted: Thu Oct 02, 2014 10:58 am
by dangladesh
I am having trouble seeing longoutput in the service details. I have looked through the documentation and believe I am formatting it properly.

I am running NagiosXI 2014R1.4, checking a host passively with NRDS. Here is the block of code that returns to Nagios server:

Code: Select all

#Nagios Return
 if [[ $lineCount -eq 0 ]]; then
     echo "LINES OK - No hung lines"
     exit $ALERT_OK
 else
     if [[ $lineCount -ge $THRESHOLD_LINES ]]; then
         ALERT_LEVEL="CRITICAL"
         EXIT_ALERT=$ALERT_CRITICAL
     else
         ALERT_LEVEL="WARNING"
         EXIT_ALERT=$ALERT_WARNING
     fi

     echo "LINES $ALERT_LEVEL - $lineCount hung lines |\c"
     for output in "${hungLine[@]}"
     do
         echo "\\n$output\c"
     done
     exit $EXIT_ALERT
fi
When run on the host, I receive the following output (newlines are interpreted by the shell):

Code: Select all

LINES WARNING - 1 hung lines |
Hung line on VRU qcolvru01 - Board 4 - Line 1 (since 10/01/2014 10:57)
However, as displayed in Service Status Detail I see only: LINES WARNING - 1 hung lines

I am wondering if I am formatting the output improperly, if there is a setting within Nagios XI I am missing, or if I am experiencing some sort of hard limit from NRDS. Any help is appreciated, thank you.

Re: Service returning longoutput

Posted: Thu Oct 02, 2014 3:23 pm
by Box293
What happens when you view this service in Nagios Core?
  • Service details page
    Click the Advanced Tab
    Click the See this Service in Nagios Core link
Do the multiple lines appear here?

Re: Service returning longoutput

Posted: Mon Oct 06, 2014 1:41 pm
by dangladesh
Box293 wrote:What happens when you view this service in Nagios Core?
  • Service details page
    Click the Advanced Tab
    Click the See this Service in Nagios Core link
Do the multiple lines appear here?
Still just a single line in Nagios Core as well.

Re: Service returning longoutput

Posted: Mon Oct 06, 2014 5:07 pm
by abrist
All performance data must be at the end of the checkresult string after the '|'. You have status information returning after the pipe on the second line. You want your script's output to resemble:

Code: Select all

LINES WARNING - 1 hung lines
Hung line on VRU qcolvru01 - Board 4 - Line 1 (since 10/01/2014 10:57) |
(notice where the pipe moved to)

Re: Service returning longoutput

Posted: Tue Oct 07, 2014 6:56 am
by jwelch
I thought it should look like:

normal status output text|perfdata text (where '|perfdata text' is optional)
detail line1
detail line2
detail line3
... up to defined limit (1.5KB?)

Re: Service returning longoutput

Posted: Tue Oct 07, 2014 9:40 am
by abrist
It did. But I think was inadvertently changed when patching a security vulv. with newlines. Try pushing your perfdata to the last line:

Code: Select all

detail line1
detail line2
detail line3 | all your perfdata

Re: Service returning longoutput

Posted: Wed Oct 08, 2014 5:28 am
by jwelch
Picking one of my custom perl check scripts at random that I know is working:

274 print "$cond - $sum|$perfdata\n$data\n";
275 exit $ERRORS{$cond};

So, unless we are talking about a change post Nagios XI 2014R1.4, this format
is working. I suspect his problem was due to not having anything after the '|'
so unless he needs perfdata I'd just remove the '|' and see if the details
show up, or change it to '| hung=1' to see if the perfdata and details show up.
Oh yeah, there was a problem with nagios 4.0.5 not correctly parsing newlines
which affected detail data display, but that was fixed in Nagios XI 2014R1.2 and
is still working as of Nagios XI 2014R1.4.

http://tracker.nagios.org/view.php?id=616

Re: Service returning longoutput

Posted: Wed Oct 08, 2014 5:07 pm
by Box293
dangladesh,
Did jwelch's suggestion work for you?

Re: Service returning longoutput

Posted: Thu Oct 09, 2014 11:38 am
by dangladesh
Box293 wrote:dangladesh,
Did jwelch's suggestion work for you?
jwelch's suggestion works when the service is returning single line output. It fails, however, when the service returns more than one line. I have tried the following outputs:

Code: Select all

STATUS | perfdata
line1
line2
line3

STATUS
line1
line2
line3
| perfdata

STATUS | perfdata
The first and last were able to successfully send perfdata. I have not yet been able to successfully return multiple lines.

This might be useful. I seem to get the following error in my var/mail directory from the cron job when multiple lines are returned by a service:

Code: Select all

/opt/nagios/nrdp/clients/nrds/nrds.pl -H 'host.domain.com' 2>&1

produced the following output:

ERROR: STDIN must be either 3 or 4 fields long, I found 1
ERROR: STDIN must be either 3 or 4 fields long, I found 1
Sent 25 checks to http://xxx.xxx.xxx.xxx/nrdp/

Re: Service returning longoutput

Posted: Thu Oct 09, 2014 5:00 pm
by Box293
Is this happening only with NDRS checks?

Have you tired creating a simple bash script (or similar) to run locally to test?