Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Checkresult output submitted through files is stored as a single line with newlines (and backslashes) escaped so Core can read the complete output as one line. The corresponding unescaping was not performed when reading back from the files. These changes correct this by unescaping the output after it is read from the checkresult file, and before any further processing. We now use one newline-delimited format internally for output data from all sources (checkresults spool, command file, workers). Perfdata from the first line was not being concatenated correctly to following lines. A space is now concatenated before additional lines, and a terminal space is not added to only be trimmed off later. In support of these changes a new unescape_newlines() functions was added to base/utils.c that performs the converse of the existing escape_newlines(). Both of these functions allocate exactly the memory needed for the new string they return, and not assume a worst case. Using the improved escape_newlines() to escape the long_output at the end of parse_check_output() eliminates an unnecessary malloc()/free() pair. The line processing code in parse_check_output() was strdup()ing each line it processed, and then memmove()ing the remaining input to the beginning of its buffer. As the memove() and earlier processing modify the input buffer anyway, this alloc/copy/free/move is entirely unneeded: the per-line processing can use the input buf directly. Modifying the line processing loop to update buf to point at the next line to process eliminates the extra memory movement. Additionally, the checkresults spool directory is now installed with the same ownership and permissions as the external command directory. This allows members of the Nagios Command group (nagcmd by default) to submit checkresults by default, and also keeps reinstalls or upgrades from resetting the ownership and permissions. All checkresult output, single or multiple line, and from all sources, should now be parsed correctly (and more efficiently) by Core.
- Loading branch information
Showing
3 changed files
with
165 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.