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

fixup! Change the notification format.

parent ec9a4bc1
No related branches found
No related tags found
No related merge requests found
Pipeline #2064 passed
...@@ -104,7 +104,7 @@ def main(): # noqa: MC0001 ...@@ -104,7 +104,7 @@ def main(): # noqa: MC0001
check.run(args.timeout) check.run(args.timeout)
except Exception as ex: # pylint: disable=broad-except except Exception as ex: # pylint: disable=broad-except
if args.errors and not args.dry_run: if args.errors and not args.dry_run:
notify(f"Check {args.command} on {HOSTNAME} failed: {ex}.") notify(f"[HOSTNAME] Check {args.command} failed: {ex}.")
parser.error(str(ex)) parser.error(str(ex))
if check.ExitCode == nagios.NagiosCode.OK: if check.ExitCode == nagios.NagiosCode.OK:
...@@ -112,21 +112,21 @@ def main(): # noqa: MC0001 ...@@ -112,21 +112,21 @@ def main(): # noqa: MC0001
elif check.ExitCode == nagios.NagiosCode.WARNING: elif check.ExitCode == nagios.NagiosCode.WARNING:
logging.info("Check status is WARNING.") logging.info("Check status is WARNING.")
if args.warn and not args.dry_run: if args.warn and not args.dry_run:
notify(f"({HOSTNAME} {check.Output}") notify(f"[{HOSTNAME}] {check.Output}")
elif check.ExitCode == nagios.NagiosCode.CRITICAL: elif check.ExitCode == nagios.NagiosCode.CRITICAL:
logging.info("Check status is CRITICAL.") logging.info("Check status is CRITICAL.")
if not args.dry_run: if not args.dry_run:
notify(f"({HOSTNAME} {check.Output}") notify(f"[{HOSTNAME}] {check.Output}")
elif check.ExitCode == nagios.NagiosCode.UNKNOWN: elif check.ExitCode == nagios.NagiosCode.UNKNOWN:
logging.info("Check status is UNKNOWN.") logging.info("Check status is UNKNOWN.")
if args.unknown and not args.dry_run: if args.unknown and not args.dry_run:
notify(f"({HOSTNAME} {check.Output}") notify(f"[{HOSTNAME}] {check.Output}")
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})."
) )
if args.errors: if args.errors:
notify(f"Check {args.command} on {HOSTNAME} status is invalid.") notify(f"[HOSTNAME] Check {args.command} status is invalid.")
if args.chain: if args.chain:
print(check._stdout) # pylint: disable=protected-access print(check._stdout) # pylint: disable=protected-access
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment