Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for embedded/encoded payloads #262

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

atc0005
Copy link
Owner

@atc0005 atc0005 commented Oct 15, 2024

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

  • add standalone functions for encoding/decoding payload content
  • add new Plugin methods for adding (append or overwrite behavior) content to be encoded and embedded as a payload
  • add new Plugin methods to override behavior
    • opt out of using delimiters (NOT RECOMMENDED)
    • use custom delimiters
    • set custom payload section label
  • minor README updates
    • note new functionality
    • refresh overview & status sections
  • add test coverage for new functionality
  • add numerous testdata input files
  • add basic examples
    • extract and decode an embedded payload from (previous) plugin output
    • add encoded payload

Credit

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

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

- add standalone functions for encoding/decoding payload content
- add new `Plugin` methods for adding (append or overwrite behavior)
  content to be encoded and embedded as a payload
- add new `Plugin` methods to override behavior
  - opt out of using delimiters (NOT RECOMMENDED)
  - use custom delimiters
  - set custom payload section label
- minor README updates
  - note new functionality
  - refresh overview & status sections
- add test coverage for new functionality
- add numerous testdata input files
- add basic examples
  - extract and decode an embedded payload from (previous) plugin
    output
  - add encoded payload

CREDIT

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

- refs #251
- refs atc0005/check-cert#960
@atc0005 atc0005 added documentation Improvements or additions to documentation enhancement New feature or request output/plugin plugin output intended for monitoring system ingest tests payload labels Oct 15, 2024
@atc0005 atc0005 added this to the v0.17.0-alpha.1 milestone Oct 15, 2024
@atc0005 atc0005 self-assigned this Oct 15, 2024
@atc0005 atc0005 merged commit 0af2aa7 into development Oct 15, 2024
28 of 29 checks passed
@atc0005 atc0005 deleted the i251-add-support-for-encoded-payloads branch October 15, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request output/plugin plugin output intended for monitoring system ingest payload tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant