CRLF in the Status Information field
-
- Posts: 4
- Joined: Mon Apr 04, 2011 4:04 pm
CRLF in the Status Information field
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
Thanks.
Sean
Re: CRLF in the Status Information field
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
http://nagiosplug.sourceforge.net/devel ... lines.html
-
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: CRLF in the Status Information field
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:
which produced this output:
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.
Code: Select all
print "Moon OK - has not yet crashed into Earth.\n" + illumination_message + "\n" + phase_message + "\n" + next_full_message
-
- Posts: 4
- Joined: Mon Apr 04, 2011 4:04 pm
Re: CRLF in the Status Information field
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
-Sean
-
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: CRLF in the Status Information field
I just confirmed that it works with the current version of NRPE (2.12), so that's not it either.
-
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: CRLF in the Status Information field
Could you perhaps attach the plugin you're using?
-
- Posts: 4
- Joined: Mon Apr 04, 2011 4:04 pm
Re: CRLF in the Status Information field
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.
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.
-
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: CRLF in the Status Information field
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?
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)
-
- Posts: 4
- Joined: Mon Apr 04, 2011 4:04 pm
Re: CRLF in the Status Information field
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
Thanks for all your help.
Regards.
Sean
-
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: CRLF in the Status Information field
Excellent.