Page 1 of 1
CRLF in the Status Information field
Posted: Mon Apr 04, 2011 4:12 pm
I trying to have multiple lines appear in the Status Information field for a check I've created. I don't seem to be able to get more than one line to display though. I've tried \n and I've tried HTML code <p> and <br> too. Is there a way to format my check's output so that it displays multiple lines?
Thanks.
Sean
Re: CRLF in the Status Information field
Posted: Mon Apr 04, 2011 7:57 pm
by mguthrie
All Nagios plugins need to have the output on one single line. This Doc is probably a little bit dated, but it gives the outline for developing Nagios plugins.
http://nagiosplug.sourceforge.net/devel ... lines.html
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 10:53 am
by tonyyarusso
Yes, that document is a bit dated.

Multi-line output is possible in the 3.x series of Nagios, but not 2.x or earlier. Using a Unix newline ("\n") is the correct way of doing this. As an example, I used the following code in a Python check plugin:
Code: Select all
print "Moon OK - has not yet crashed into Earth.\n" + illumination_message + "\n" + phase_message + "\n" + next_full_message
which produced this output:

- multi-line-output.png (9.77 KiB) Viewed 6491 times
Note however that this will only display on the detail page for the particular service. The multiple-service tables such as the host status detail listing will still only display the first line.
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 11:40 am
That's for your help. I'm running 3.0.6. The first thing I tried was the "\n" but it's not showing up in the Status Information field. I'm using nrpe to bring the data into Nagios. Could nrpe be truncating the output after the first crlf?
-Sean
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 12:20 pm
by tonyyarusso
I just confirmed that it works with the current version of NRPE (2.12), so that's not it either.
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 12:21 pm
by tonyyarusso
Could you perhaps attach the plugin you're using?
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 1:09 pm
Here are the last few lines of the perl script that take care for formatting the data...
my $message = qw{};
foreach my $channel_name ( keys %channel){
$message = $message . "[ $channel_name :";
foreach my $key( keys %{$channel{$channel_name}}){
if( $key eq 'D' ) { $action_code = 'Deque'; }
elsif( $key eq 'E' ) { $action_code = 'Enqueue'; }
else{ next; }
$message = $message . " $channel{$channel_name}->{$key} $action_code";
}
$message = $message . " ]\n";
}
print "$message";
exit(0);
Here is what the output looks like on the host...
# ./collect_mta_log
[ tcp_intranet : 72 Deque 72 Enqueue ]
[ ims-ms : 102 Deque 102 Enqueue ]
[ reprocess : 0 Deque 0 Enqueue ]
[ tcp_pimp : 72 Deque 72 Enqueue ]
[ tcp_local : 4 Deque 3 Enqueue ]
[ process : 145 Deque 145 Enqueue ]
After Nagios it's taken in through NRPE only the first line is visible.

- Screen shot 2011-04-05 at 11.01.41 AM.png (38.04 KiB) Viewed 6482 times
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 2:13 pm
by tonyyarusso
First, could you confirm what version of NRPE you're using and what OS these are on?
Second, could you humour me by trying this ultra-simplified plugin just to rule out any plugin-specific issues?
Code: Select all
#!/usr/bin/env python
import sys
print "Checking multi-line output...\nIf you see this line it succeeded.\nCongrats!"
sys.exit(0)
Re: CRLF in the Status Information field
Posted: Tue Apr 05, 2011 5:31 pm
AH, got it. We were running nrpe 2.0.6. I upgrade to the latest rev. and I'm getting the multi-line output.
Thanks for all your help.
Regards.
Sean
Re: CRLF in the Status Information field
Posted: Wed Apr 06, 2011 9:29 am
by tonyyarusso
Excellent.
