Fix an incorrect hyphen removal due to a double linefeed#25
Fix an incorrect hyphen removal due to a double linefeed#25
Conversation
|
Hi Ton! I tried to make sense of this... While the fix is sound, long output seem to be a somewhat undocumented feature of N::P. In particular it wouldn't respect the standard v3 plugin format (I'm not sure how Nagios & others cope with this though, maybe it's OK regardless...) The format since v3 is defined as: Yet the first perfdata would start to appear at Furthermore there is no room for a short status text (ex something that can easily fit in an sms or other short notification message). So why not instead split on the first If long output facilities are added in the future it could allow either long output/perfdata or newlines in short output, not both, for a smooth transition. I'm also a bit worried about allowing |
|
P.S.: Maybe a good opportunity to dust-off my Perl... Though it will definitively give me the impression of being stuck in an infinite loop... Bash, Perl, Python, Bash, Perl, ... :D |
|
Hi Thomas! Good question. I hadn't considered the perfdata angle of it. It looks like Sven made changes around the line, but my biggest beef is that the testcases weren't updated to cover what was trying to be achieved. The key will be adding further test cases and then code to that. Could you add tests for what you expect? |
|
Looking at the history of that line, we had Then we had which did not work with < 5.8 then So looking at the number of changes for this little regex, i totally agree and we really need more testcases here. |
Given a message of "LONGOUTPUT\n\n blah.", the plugin_exit() message gave: "MONITORING-PLUGIN-FUNCTIONS-01 CRITICALLONGOUTPUT\n\n blah.\n", which was wrong.
This was located as the regex in this line:
I have amended the line to:
which kinda makes sense - it means if the message starts with (optional) spaces and then a linefeed, ignore the hyphen. The previous modifiers of /mxs started to match other parts of the string.
Have added a test case to cover this and also update the test to check for the precise output (rather than the looser regex check).