Closed pdugas closed 8 years ago
does $plugin->plugin_exit(OK, "All good\nadditional\ndetails\nhere")
work?
That's what I'm doing in the interim. However, when the $message is empty we call $plugin->plugin_exit(OK, "\nadditional\ndetails\nhere")
and end up with output like so
OK -
additional
details
here|perfdata
The extra dash in the output is apparently annoying so some of my people. Maybe it'd be easier to just look for a leading \n in $message and skip the dash in that case.
--- Functions.pm.orig 2016-03-31 14:50:52.295849074 -0400
+++ Functions.pm 2016-03-31 14:55:17.350834574 -0400
@@ -118,7 +118,10 @@
# Setup output
my $output = "$STATUS_TEXT{$code}";
- $output .= " - $message" if defined $message && $message ne '';
+ if (defined $message && $message ne '') {
+ $output .= " - " unless $message =~ /^ *\n/;
+ $output .= $message;
+ }
my $shortname = ($arg->{plugin} ? $arg->{plugin}->shortname : undef);
$shortname ||= get_shortname(); # Should happen only if funnctions are called directly
$output = "$shortname $output" if $shortname;
Sounds ok for me, could you create a pull request? Then i could just merge it and you get proper credits.
and i would use /^\s*\n/;
I had \s
initially but that matches the \n
and the test would pass for " foo"
as well as " \nfoo"
.
I guess I could use [ \f\r\t\w]
which is what \s
expands to minus the \n
. Not terribly clean.
ah yes, you are right :-)
merged in #10
thanks
That regex isn't correct. My testing yesterday was minimal and insufficient. I'm working on fixing it still but am having to dust off my multiline matching foo. It needs a /m or /s. Will let you know if I can fix it.
Paul Dugas, Computer Engineer Dugas Enterprises, LLC http://www.dugasenterprises.com/ 522 Black Canyon Park, Canton, GA 30114 USA http://maps.google.com/?q=522%20Black%20Canyon%20Park,%20Canton,%20GA,%2030114%20,USA o: 404-590-5159 | m: 404-932-1355 | e: paul@dugasenterprises.com
On Thu, Mar 31, 2016 at 6:02 PM, Sven Nierlein notifications@github.com wrote:
thanks
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/monitoring-plugins/monitoring-plugin-perl/issues/9#issuecomment-204149345
I'd like to be able to use something like the code below to emit additional lines of LONGOUTPUT from a plugin.
The output from this would be something like