Skip to content
Snippets Groups Projects
Commit ea4bd684 authored by nimrod's avatar nimrod
Browse files

Better notifications and output.

- Use the parsed plugin output in the notification.
- Log more of the plugin output.
parent 5eb9cfe1
No related branches found
No related tags found
No related merge requests found
...@@ -94,24 +94,36 @@ def main(): # noqa: MC0001 ...@@ -94,24 +94,36 @@ def main(): # noqa: MC0001
if check.ExitCode == nagios.NagiosCode.OK: if check.ExitCode == nagios.NagiosCode.OK:
logging.info("Check status is 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: elif check.ExitCode == nagios.NagiosCode.WARNING:
logging.info("Check status is 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: 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: elif check.ExitCode == nagios.NagiosCode.CRITICAL:
logging.info("Check status is CRITICAL.") logging.info("Check status is CRITICAL.")
logging.info(check.Output)
logging.info(check.AdditionalOutput)
logging.info(check.stderr)
if not args.dry_run: 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: elif check.ExitCode == nagios.NagiosCode.UNKNOWN:
logging.info("Check status is 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: if args.unknown and not args.dry_run:
notify( notify(f"{check.Output} on {HOSTNAME}.")
f"Check {args.command} on {HOSTNAME} is in an unknown state."
)
else: else:
logging.info( logging.info(
f"Check status is invalid for a Nagios plugin ({check.ExitCode})." f"Check status is invalid for a Nagios plugin ({check.ExitCode})."
) )
logging.info(check._stdout)
logging.info(check.stderr)
if args.errors: if args.errors:
notify(f"Check {args.command} on {HOSTNAME} status is invalid.") notify(f"Check {args.command} on {HOSTNAME} status is invalid.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment