Page 3 of 5
Re: Email of multiline output
Posted: Mon Oct 25, 2021 4:01 pm
by pbroste
Hello
@hbouma
Thanks for sending the info over, what do you get when you send it via email event handler? Here is a raw example from 'sendmail':
--b1_c8db6785341588857ce41a6c635c1852
Content-Type: text/html; charset=us-ascii
***** Nagios XI Alert *****<br />
<br />
Nagios has detected a problem with this service.<br />
<br />
Notification Type: PROBLEM<br />
<br />
Service: Plugin check_files.ps1<br />
Host: xxx.xxx.xxx.xxx<br />
Address: xxx.xxx.xxx.xxx<br />
State: CRITICAL<br />
Info:<br />
Files modified in the last 9999 minutes. Files are:<br />
Date/Time: 2021-10-25 15:48:41<br />
<br />
Respond:
http://xxx.xxx.xxx.xxx/nagiosxi/rr.php? ... 1851b31<br />
Nagios URL:
http://xxx.xxx.xxx.xxx/nagiosxi/<br />
Add: C:\temp\New Text Document (4) - Copy - Copy.txt\nC:\temp\this_is_new_file - Copy (2).txt\nC:\temp\this_is_new_file - Copy (3).txt\nC:\temp\this_is_new_file - Copy (4).txt\nC:\temp\this_is_new_file - Copy.txt\nC:\temp\this_is_new_file.txt\n\n\t<br />
Thanks,
Perry
Re: Email of multiline output
Posted: Tue Oct 26, 2021 6:58 am
by hbouma
Things did not turn out as expected. I have sent you a PM.
Re: Email of multiline output
Posted: Tue Oct 26, 2021 3:48 pm
by pbroste
Hello
@hbouma
Which event_handler did you select for the 'check_files' Event Handler pull-down list?[
Example that I utilized for testing:
xi_service_event_handler /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=service --host="$HOSTNAME$" --service="$SERVICEDESC$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --servicedowntime=$SERVICEDOWNTIME$
Please verify that the line '--longserviceoutput="$LONGSERVICEOUTPUT$"' correlates with that Event Handler associated with the check_files service check.
Thanks,
Perry
Re: Email of multiline output
Posted: Wed Oct 27, 2021 6:51 am
by hbouma
I think there is some confusion here. The Event Handler is never used to send the emails, and the problem we are having is with emails sent by Nagios XI.
To answer your question, I created a new command by cloning the notify-service-by-email check and altering the clone to have the following command:
/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\n Info:\n\n$SERVICEOUTPUT$ Additional line2Info: \n$LONGSERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ $LONGDATETIME$ **" $CONTACTS$
I will send you an PM with a manual run of this command and the email I receive.
Re: Email of multiline output
Posted: Wed Oct 27, 2021 1:49 pm
by pbroste
Hello
@hbouma
Thanks for following up with the PM.
Here are the following can be used for formating:
- \r represents the carriage return
- \n the newline (linefeed)
- \t for tab
I tested with
\r\n; to initate carriage return and follow up with newline.
Thanks,
Perry
Re: Email of multiline output
Posted: Thu Oct 28, 2021 6:33 am
by hbouma
PM sent
Re: Email of multiline output
Posted: Thu Oct 28, 2021 1:10 pm
by pbroste
Hello
@hbouma
Thanks for following up, in looking into the email formating the 'sendmail' is using the postfix backend. There are some options or aka
mta alternatives that we can set.
alternatives --config mta
There is 1 program that provides 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.postfix
2 /usr/sbin/sendmail.ssmtp
Please test email formatting for your 'check_files' service check.
Thanks,
Perry
hbouma wrote:Subject: Email of multiline output
pbroste wrote:Hello
@hbouma
Thanks for following up with the PM.
Here are the following can be used for formating:
- \r represents the carriage return
- \n the newline (linefeed)
- \t for tab
I tested with
\r\n; to initate carriage return and follow up with newline.
Thanks,
Perry
Command being sent using \n and \r for new line.
Email output.
ATT00001.txt
FYI, the \f in the path is actually turning into ASCII character 12 in the email message.
I am curious, is Nagios using /bin/mail when it sends the mail? We are not sending the mail ourselves with any special characters being selected by us. Instead, we are using the default notifications built into Nagios XI.
Re: Email of multiline output
Posted: Thu Nov 04, 2021 8:00 am
by hbouma
We only have the postfix sendmail option.
$ alternatives --config mta
There is 1 program that provides 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number:
Re: Email of multiline output
Posted: Fri Nov 05, 2021 9:55 am
by pbroste
Hello
@hbouma
I will do further testing on this to see if there are any workarounds and follow up. It does appear that we are limited on formatting options available for postfix.
Regards,
Perry
Re: Email of multiline output
Posted: Mon Nov 22, 2021 4:23 am
by hbouma
pbroste wrote:Hello
@hbouma
I will do further testing on this to see if there are any workarounds and follow up. It does appear that we are limited on formatting options available for postfix.
Regards,
Perry
Hi, I just wanted to followup on this and see if anything was found.