From 30f234d42ddfd9e615a5016a258068d0a72d7fe3 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Mon, 26 Nov 2012 17:08:13 -0500 Subject: [PATCH] send-nagios-notification: Expand "\n" escape sequences that we get from Nagios (imported from commit 3e8efbfe8bbd5a2f13a8e02d9f44442b035113ba) --- bots/send-nagios-notification | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bots/send-nagios-notification b/bots/send-nagios-notification index c28abc6..77a6b35 100755 --- a/bots/send-nagios-notification +++ b/bots/send-nagios-notification @@ -35,7 +35,10 @@ else: # e.g. **PROBLEM**: service is CRITICAL msg['content'] = '**%s**: %s is %s' % (opts.type, thing, opts.state) -output = (opts.output + '\n' + opts.long_output).strip() +# The "long output" can contain newlines represented by "\n" escape sequences. +# The Nagios mail command uses /usr/bin/printf "%b" to expand these. +# We will be more conservative and handle just this one escape sequence. +output = (opts.output + '\n' + opts.long_output.replace(r'\n', '\n')).strip() if output: # Block-quote any command output. msg['content'] += ('\n\n' + '\n'.join('> ' + ln for ln in output.splitlines()))