CRLF in the Status Information field

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
sean.mason@apple.com
Posts: 4
Joined: Mon Apr 04, 2011 4:04 pm

CRLF in the Status Information field

Post by sean.mason@apple.com »

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
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: CRLF in the Status Information field

Post 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
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: CRLF in the Status Information field

Post by tonyyarusso »

Yes, that document is a bit dated. :P 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
multi-line-output.png (9.77 KiB) Viewed 6087 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.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
sean.mason@apple.com
Posts: 4
Joined: Mon Apr 04, 2011 4:04 pm

Re: CRLF in the Status Information field

Post by sean.mason@apple.com »

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
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: CRLF in the Status Information field

Post by tonyyarusso »

I just confirmed that it works with the current version of NRPE (2.12), so that's not it either.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: CRLF in the Status Information field

Post by tonyyarusso »

Could you perhaps attach the plugin you're using?
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
sean.mason@apple.com
Posts: 4
Joined: Mon Apr 04, 2011 4:04 pm

Re: CRLF in the Status Information field

Post by sean.mason@apple.com »

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
Screen shot 2011-04-05 at 11.01.41 AM.png (38.04 KiB) Viewed 6078 times
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: CRLF in the Status Information field

Post 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)
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
sean.mason@apple.com
Posts: 4
Joined: Mon Apr 04, 2011 4:04 pm

Re: CRLF in the Status Information field

Post by sean.mason@apple.com »

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
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: CRLF in the Status Information field

Post by tonyyarusso »

Excellent. :)
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Locked