Add support for embedded/encoded payloads #262
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Add support for embedding an encoded payload within and later extracting the payload from plugin output.
The current Nagios plugin API permits returning human readable information to Nagios for display in a web UI or notifications and metrics for calculations & other data manipulation purposes. As far as I know, Nagios does not permit passing something like a JSON payload directly between the plugin and the monitoring system.
This new (optional) support provides a way for plugins to safely & reliably embed content (e.g., JSON data) within the generated output which can later be extracted by other tools.
Due to current Nagios plugin output length restrictions (8192 bytes), the use of encoded payloads should be used sparingly.
Changes
Plugin
methods for adding (append or overwrite behavior) content to be encoded and embedded as a payloadPlugin
methods to override behaviorCredit
I consulted ChatGPT when planning the implementation. While later iterations of the code differed significantly, ChatGPT provided code samples that acted as a starting point for the initial encoding/decoding functionality.
Discussions with ChatGPT proved very helpful when deciding between using the base64 encoding format (more common, but less efficient) and the base85 (aka, "Ascii85") encoding format (more efficient). Those discussions also covered concerns such as adhering to the default
illegal_macro_output_chars
requirements that Nagios imposes for plugin output.References
LongServiceOutput
content check-cert#960