Issue with email format
Issue with email format
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
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
Re: Issue with email format
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!
Re: Issue with email format
Attached is a screenshot from the nagios ui, where you can see the multiline status informationlmiltchev 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.
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$
}
Re: Issue with email format
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:
In Nagios Core:
Notification command:
Actual notification received:
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;100Code: 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$
}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!
Re: Issue with email format
Nagios Core 3.5.1lmiltchev 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:In Nagios Core: Notification command: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;100Actual notification received: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$ }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%);
Re: Issue with email format
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!
Re: Issue with email format
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.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.
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
This doesn't really answer your question - but just to satisfy the curiosity of an unknowing support forum tech - what is PNP4Nagios2.0?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
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.
Re: Issue with email format
pnp4nagios is the graphing add-on for nagios, that graphs the performance data. Yes that's the command I am using.jdalrymple wrote:This doesn't really answer your question - but just to satisfy the curiosity of an unknowing support forum tech - what is PNP4Nagios2.0?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
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.
Re: Issue with email format
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?
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!