From ea4bd68475fc32b2933c55f6e11d8732fbaba30f Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Sat, 31 Jul 2021 20:48:24 +0300 Subject: [PATCH] Better notifications and output. - Use the parsed plugin output in the notification. - Log more of the plugin output. --- mnpw/__init__.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/mnpw/__init__.py b/mnpw/__init__.py index 6b0e010..a2ca8d5 100644 --- a/mnpw/__init__.py +++ b/mnpw/__init__.py @@ -94,24 +94,36 @@ def main(): # noqa: MC0001 if check.ExitCode == nagios.NagiosCode.OK: logging.info("Check status is OK.") + logging.info(check.Output) + logging.info(check.AdditionalOutput) + logging.info(check.stderr) elif check.ExitCode == nagios.NagiosCode.WARNING: logging.info("Check status is WARNING.") + logging.info(check.Output) + logging.info(check.AdditionalOutput) + logging.info(check.stderr) if args.warn and not args.dry_run: - notify(f"Check {args.command} on {HOSTNAME} returned a warning.") + notify(f"{check.Output} on {HOSTNAME}.") elif check.ExitCode == nagios.NagiosCode.CRITICAL: logging.info("Check status is CRITICAL.") + logging.info(check.Output) + logging.info(check.AdditionalOutput) + logging.info(check.stderr) if not args.dry_run: - notify(f"Check {args.command} on {HOSTNAME} is critical!") + notify(f"{check.Output} on {HOSTNAME}.") elif check.ExitCode == nagios.NagiosCode.UNKNOWN: logging.info("Check status is UNKNOWN.") + logging.info(check.Output) + logging.info(check.AdditionalOutput) + logging.info(check.stderr) if args.unknown and not args.dry_run: - notify( - f"Check {args.command} on {HOSTNAME} is in an unknown state." - ) + notify(f"{check.Output} on {HOSTNAME}.") else: logging.info( f"Check status is invalid for a Nagios plugin ({check.ExitCode})." ) + logging.info(check._stdout) + logging.info(check.stderr) if args.errors: notify(f"Check {args.command} on {HOSTNAME} status is invalid.") -- GitLab