Issue with email format

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Issue with email format

Post by stecino »

Hello,

In the status information of the service, I have a multiline message, but when the email notification is sent out it's in one line. Is there a way to fix it.
Even in my python code I add carriage returns to each line gets printed, but that didn't fix it.

Thanks in advance
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Issue with email format

Post by lmiltchev »

Can you show us an example of your multiline message and what you actually receive as a notification? Also, show us the notification command that you are using.
Be sure to check out our Knowledgebase for helpful articles and solutions!
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

lmiltchev wrote:Can you show us an example of your multiline message and what you actually receive as a notification? Also, show us the notification command that you are using.
Attached is a screenshot from the nagios ui, where you can see the multiline status information


Here is the email body, where the same status info is not multiline

***** Nagios *****

Notification Type: PROBLEM
Comment:

Service: batchPushMessagesTask
Host: nagios
Address: 127.0.0.1
State: CRITICAL

Date/Time: Thu Jun 18 11:49:41 PDT 2015

Additional Info:

Server sbur2app03 has 3 batch push messages that are older than 5 minutes Server sbur2app01 has 2 batch push messages that are older than 5 minutes

This is my command definition

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nComment: $SERVICEACKCOMMENT$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /bin/mail -s "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ " $CONTACTEMAIL$
}
Attachments
batchPushMessages.png
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Issue with email format

Post by lmiltchev »

What is the version of Nagios Core that you are using?

I was not able to recreate the issue. I tested the multiline in Nagios XI, but I am running Nagios Core 4.0.8 underneath. The $LONGSERVICEOUTPUT$ seems to work fine for me.

From the CLI:

Code: Select all

./check_disk -w 20 -c 10 -A -n
DISK OK - free space:
 / 9227 MB (55% inode=91%);
 /dev/shm 938 MB (100% inode=99%);
 /boot 361 MB (80% inode=99%);
 /var/nagiosramdisk 99 MB (99% inode=99%);
| /=7423MB;17523;17533;0;17543 /dev/shm=0MB;918;928;0;938 /boot=89MB;456;466;0;476 /var/nagiosramdisk=0MB;80;90;0;100
In Nagios Core:
example01.PNG
Notification command:

Code: Select all

define command {
       command_name                  		notify-service-by-email
       command_line                  		/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\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Actual notification received:

Code: Select all

***** Nagios Monitor XI Alert *****

Notification Type: CUSTOM

Service: Multiline Disk
Host: localhost
Address: 127.0.0.1
State: OK

Date/Time: Fri Jun 19 09:45:17 CDT 2015

Additional Info:

DISK OK - free space:
 / 8829 MB (53% inode=91%);
 /dev/shm 938 MB (100% inode=99%);
 /boot 361 MB (80% inode=99%);
 /var/nagiosramdisk 99 MB (99% inode=99%);
Be sure to check out our Knowledgebase for helpful articles and solutions!
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

lmiltchev wrote:What is the version of Nagios Core that you are using?

I was not able to recreate the issue. I tested the multiline in Nagios XI, but I am running Nagios Core 4.0.8 underneath. The $LONGSERVICEOUTPUT$ seems to work fine for me.

From the CLI:

Code: Select all

./check_disk -w 20 -c 10 -A -n
DISK OK - free space:
 / 9227 MB (55% inode=91%);
 /dev/shm 938 MB (100% inode=99%);
 /boot 361 MB (80% inode=99%);
 /var/nagiosramdisk 99 MB (99% inode=99%);
| /=7423MB;17523;17533;0;17543 /dev/shm=0MB;918;928;0;938 /boot=89MB;456;466;0;476 /var/nagiosramdisk=0MB;80;90;0;100
In Nagios Core:
example01.PNG
Notification command:

Code: Select all

define command {
       command_name                  		notify-service-by-email
       command_line                  		/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\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Actual notification received:

Code: Select all

***** Nagios Monitor XI Alert *****

Notification Type: CUSTOM

Service: Multiline Disk
Host: localhost
Address: 127.0.0.1
State: OK

Date/Time: Fri Jun 19 09:45:17 CDT 2015

Additional Info:

DISK OK - free space:
 / 8829 MB (53% inode=91%);
 /dev/shm 938 MB (100% inode=99%);
 /boot 361 MB (80% inode=99%);
 /var/nagiosramdisk 99 MB (99% inode=99%);
Nagios Core 3.5.1
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Issue with email format

Post by lmiltchev »

Is there a chance that you spin up a test VM with Nagios Core 4.0.8 and test your check there? If the issue is resolved in Core 4, you can possibly upgrade.
Be sure to check out our Knowledgebase for helpful articles and solutions!
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

lmiltchev wrote:Is there a chance that you spin up a test VM with Nagios Core 4.0.8 and test your check there? If the issue is resolved in Core 4, you can possibly upgrade.
Unfortunately, it's not the best option for me right now. Initially I had Nagios Core 4.0.x installed, but it turned out not to be compatible with PNP4Nagios2.0, so the only solution based on different boards was to downgrade to latest 3.x.
Is there a workaround for this? Maybe creating a custom Macro that may add carriage returns prior to sending out?
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Issue with email format

Post by jdalrymple »

stecino wrote:Unfortunately, it's not the best option for me right now. Initially I had Nagios Core 4.0.x installed, but it turned out not to be compatible with PNP4Nagios2.0
This doesn't really answer your question - but just to satisfy the curiosity of an unknowing support forum tech - what is PNP4Nagios2.0?

More to the point of solving your problem - are you certain you're using the command you posted? I have a lot of Core 3.5.x experience and it always has (and still today) sends me multiline E-mails just fine using the default notify-by-email commands. I would double check your contact definition.
stecino
Posts: 248
Joined: Thu Mar 14, 2013 4:42 pm

Re: Issue with email format

Post by stecino »

jdalrymple wrote:
stecino wrote:Unfortunately, it's not the best option for me right now. Initially I had Nagios Core 4.0.x installed, but it turned out not to be compatible with PNP4Nagios2.0
This doesn't really answer your question - but just to satisfy the curiosity of an unknowing support forum tech - what is PNP4Nagios2.0?

More to the point of solving your problem - are you certain you're using the command you posted? I have a lot of Core 3.5.x experience and it always has (and still today) sends me multiline E-mails just fine using the default notify-by-email commands. I would double check your contact definition.
pnp4nagios is the graphing add-on for nagios, that graphs the performance data. Yes that's the command I am using.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Issue with email format

Post by tgriep »

Do you have any other multi-line plugins running and are they working?
Can you run your check from a shell on your server and post the output here?
Can you upload your script so we can review it?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked