You’ll have to create duplicate contacts and in the duplicates you would set a command for host_notification_commands/service_notification_commands that is defined to run a script.
The multi.sh script would read the multiline output to a variable which you could send by an email:
#!/bin/bash
output=cat /tmp/output.file
/usr/bin/printf “%b” “***** Nagios \n\nNotification Type: $NOTIFICATIONTYPE\n\nService: $SERVICEDESC\nHost: $HOSTALIAS\nAddress
: $HOSTADDRESS\nState: $SERVICESTATE\n\nDate/Time: $LONGDATETIME\n\nAdditional Info:\n\n$SERVICEOUTPUT\n$output" | /usr/bin/mail -a"X
-Alert: nagios" -s "* $NOTIFICATIONTYPE Service Alert: $HOSTALIAS/$SERVICEDESC is $SERVICESTATE **” $CONTACTEMAIL
The bolded part is an output from a file with multiline output. The only thing you’ll have to deal with is handling the macro variables from nagios. You can forward them to this script through a command definition after a command_line variable as input variables for a bash script ($1, $2, $3 etc.) or you can enable environment variables in nagios.cfg which would make them accesible all over the system (but it slows down the system, read the explanation about it in nagios.cfg).
I am slightly confused about the answer.
What I am trying is simply to have multiple lines in a passive check shown within nagios itself.
When I submit a check result to the …/rw/nagios.cmd file to a passive service, I have only one line because a return is interpreted as the end of the message. I mean “plugin_output” can’t contain a newline character?