Service returning longoutput

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
dangladesh
Posts: 17
Joined: Thu Jul 24, 2014 3:13 pm

Service returning longoutput

Post 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.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Service returning longoutput

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dangladesh
Posts: 17
Joined: Thu Jul 24, 2014 3:13 pm

Re: Service returning longoutput

Post 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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Service returning longoutput

Post 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)
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jwelch
Posts: 225
Joined: Wed Sep 05, 2012 12:49 pm

Re: Service returning longoutput

Post 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?)
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Service returning longoutput

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
jwelch
Posts: 225
Joined: Wed Sep 05, 2012 12:49 pm

Re: Service returning longoutput

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Service returning longoutput

Post by Box293 »

dangladesh,
Did jwelch's suggestion work for you?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
dangladesh
Posts: 17
Joined: Thu Jul 24, 2014 3:13 pm

Re: Service returning longoutput

Post 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/
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Service returning longoutput

Post by Box293 »

Is this happening only with NDRS checks?

Have you tired creating a simple bash script (or similar) to run locally to test?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked