I just installed Nagios 3.4 on RHEL 6.
After configuration, email notifications are failing.
All macros are being passed un-interpreted:
Subject: $HOSTNAME$ is $HOSTSTATE$
***** Nagios *****\n\n\nHost shnagiosp00$ [$] is $\n\nDate/Time: $\n
here are my command defininitions:
# 'host-notify-by-email' command definition
define command{
command_name host-notify-by-email
command_line /bin/echo "***** Nagios *****\n\n$HOSTALIAS\nHost $HOSTNAME$ [$HOSTADDRESS$] is $HOSTSTATE$\n\nDate/Time: $SHORTDATETIME$\n" | /bi
n/mailx -r "[email protected]" -s '$HOSTNAME$ is $HOSTSTATE$' $CONTACTEMAIL$
}
# 'host-notify-by-pager' command definition
define command{
command_name host-notify-by-pager
command_line /bin/echo "***** Nagios *****\n\n$HOSTALIAS\nHost $HOSTNAME$ [$HOSTADDRESS$] is $HOSTSTATE$\n\nDate/Time: $SHORTDATETIME$\n" | /bi
n/mailx -r "[email protected]" -s '$HOSTNAME$ is $HOSTSTATE$' $CONTACTPAGER$
}
# 'host-notify-by-both' command definition
define command{
command_name host-notify-by-both
command_line /bin/echo "***** Nagios *****\n\n$HOSTALIAS\nHost $HOSTNAME$ [$HOSTADDRESS$] is $HOSTSTATE$\n\nDate/Time: $SHORTDATETIME$\n" | /bi
n/mailx -r "[email protected]" -s '$HOSTNAME$ is $HOSTSTATE$' $CONTACTEMAIL$ $CONTACTPAGER$
}
And I have tried setting illegal_macro_output_chars both ways.
Has anyone seen this, and know how to correct?
Nagios 3.4 Macros not substituting on RHEL 6
Re: Nagios 3.4 Macros not substituting on RHEL 6
Below are the defaults:
Did you write these notification command definitions yourself? Are the macros working in other areas of nagios (checks and reporting)? Any reason why you chose "echo" over "printf"?
Have these commands worked for you in the past?
Code: Select all
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# '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$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Have these commands worked for you in the past?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: Nagios 3.4 Macros not substituting on RHEL 6
abrist, Thanks for your reply.
These command definitions were lifted from our existing Nagios 3.1 server which is running on Solaris 10.
I did not write them myself, it is legacy code inherited from a previous sysadmin at this site.
They work fine on the 3.2 Solaris server. But now we are migrating to RHEL 6.
I wonder if the "echo" changes were made to accomodate Solaris? This code has been transferred twice, the original build was on Solaris 9, and a much earlier verion of Nagios. I was not here for that first build, but I built the Solaris 10 server and implemented the Nagios 3.1 there, and transferred most of the config code from the first build.
At any rate, I will try the changes you have proposed and post back.
In the mean time, I have a question that occured to me overnight: Are there any compile or configure options that affect the implementation of Macros on 3.4 that you are aware of?
These command definitions were lifted from our existing Nagios 3.1 server which is running on Solaris 10.
I did not write them myself, it is legacy code inherited from a previous sysadmin at this site.
They work fine on the 3.2 Solaris server. But now we are migrating to RHEL 6.
I wonder if the "echo" changes were made to accomodate Solaris? This code has been transferred twice, the original build was on Solaris 9, and a much earlier verion of Nagios. I was not here for that first build, but I built the Solaris 10 server and implemented the Nagios 3.1 there, and transferred most of the config code from the first build.
At any rate, I will try the changes you have proposed and post back.
In the mean time, I have a question that occured to me overnight: Are there any compile or configure options that affect the implementation of Macros on 3.4 that you are aware of?
Re: Nagios 3.4 Macros not substituting on RHEL 6
abrist,
I found my original problem.
further down in my commands.cfg file I had some more host-notify-by-email, pager and both definitions that had several macros that did not have the terminating "$" on their trailing end:
$HOSTSTATE $CONTACTEMAIL
I don't know why those did NOT show up on the Solaris impelmentation. I have corrected those, and changed the "*****" to "#####" just to prevent any further adverse interaction with local shells, and implemented printf vice echo.
Thanks again for your help.
I found my original problem.
further down in my commands.cfg file I had some more host-notify-by-email, pager and both definitions that had several macros that did not have the terminating "$" on their trailing end:
$HOSTSTATE $CONTACTEMAIL
I don't know why those did NOT show up on the Solaris impelmentation. I have corrected those, and changed the "*****" to "#####" just to prevent any further adverse interaction with local shells, and implemented printf vice echo.
Thanks again for your help.
Re: Nagios 3.4 Macros not substituting on RHEL 6
Not that I know of. There were a number of macro fixes between early versions of 3 and 3.2.2. Are you having problems with macros?davidbost wrote: In the mean time, I have a question that occured to me overnight: Are there any compile or configure options that affect the implementation of Macros on 3.4 that you are aware of?
That will most definitely create interesting problems. I have no idea why solaris was not complaining, though it may also have to do with how old the previous core install was.davidbost wrote:further down in my commands.cfg file I had some more host-notify-by-email, pager and both definitions that had several macros that did not have the terminating "$" on their trailing end:
Are notifications/alerts working correctly now?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.