Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Monitoring/Plugin/Functions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ sub plugin_exit {
# Setup output
my $output = "$STATUS_TEXT{$code}";
if (defined $message && $message ne '') {
$output .= " - " unless $message =~ /^\s*\n/mxs;
$output .= " - " unless $message =~ /^\s*[\n\r]/;
$output .= $message;
}
my $shortname = ($arg->{plugin} ? $arg->{plugin}->shortname : undef);
Expand Down
13 changes: 6 additions & 7 deletions t/Monitoring-Plugin-Functions-01.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

use strict;
use Test::More tests => 116;
use Test::More tests => 117;

BEGIN { use_ok("Monitoring::Plugin::Functions", ":all"); }
Monitoring::Plugin::Functions::_fake_exit(1);
Expand Down Expand Up @@ -90,15 +90,14 @@ for (@ugly2) {

# plugin_exit message with longoutput
my @ugly3 = (
[ "MSG\nLONGOUTPUT", " - MSG\nLONGOUTPUT" ],
[ "\nLONGOUTPUT", "\nLONGOUTPUT" ],
[ " \nLONGOUTPUT", " \nLONGOUTPUT" ],
[ "MSG\nLONGOUTPUT", "MONITORING-PLUGIN-FUNCTIONS-01 CRITICAL - MSG\nLONGOUTPUT\n" ],
[ "\nLONGOUTPUT", "MONITORING-PLUGIN-FUNCTIONS-01 CRITICAL\nLONGOUTPUT\n" ],
[ " \nLONGOUTPUT", "MONITORING-PLUGIN-FUNCTIONS-01 CRITICAL \nLONGOUTPUT\n" ],
[ "LONGOUTPUT\n\n blah.", "MONITORING-PLUGIN-FUNCTIONS-01 CRITICAL - LONGOUTPUT\n\n blah.\n" ],
);
for (@ugly3) {
$r = plugin_exit(CRITICAL, $_->[0]);
like($r->message, qr/CRITICAL$_->[1]$/,
sprintf('plugin_exit(CRITICAL, $msg) output matched "%s"',
"CRITICAL$_->[1]"));
is($r->message, $_->[1], "plugin_exit() output as expected");
}

# Test plugin_die( $msg )
Expand Down