Email notifications. Unsupported macro???

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.
Locked
stageitp
Posts: 4
Joined: Tue Jan 03, 2012 2:29 pm

Email notifications. Unsupported macro???

Post by stageitp »

Dear Nagios users,

I am running a Groundwork Monitoring server on top of Nagios Core 3.2.3. I want to use the notification option so that a notification contact is used when a host state has changed.

I'm using the Sendemail script on Linux which has to use the $CONTACTEMAIL$ macro to use the e-mail address(es) of the notification contacts.

The problem is that the script can't read the macro. It can however, read a e-mail address.

-t $CONTACTEMAIL$ = Jan 03 15:42:11 gwositp sendEmail[29801]: Error: "-" is not a recognized option!

-t [email protected] = Jan 03 15:43:08 gwositp sendEmail[30388]: Message input complete.
Jan 03 15:43:10 gwositp sendEmail[30388]: Email was sent successfully!

Code: Select all

/usr/bin/printf "%b" "<html> Host: $NOTIFICATIONTYPE$ : <b>$HOSTSTATE$</b><br>Datum: <b>$LONGDATETIME$</b><br>Host: <b>$HOSTALIAS$ ($HOSTADDRESS$)</b></b><br><br>Note: You are getting this e-mail because there was a state change of the host. Please refer to the Groundwork server for the actual problem.<br><br><b>$HOSTOUTPUT$</b></html>" | /usr/local/groundwork/common/bin/sendEmail -s $USER13$ -xu $USER14$ -xp $USER15$ -f $ADMINEMAIL$ -t $CONTACTEMAIL$ -u Groundwork ITP
Is there any fix for the...what it seems like...unsupported macro?
stageitp
Posts: 4
Joined: Tue Jan 03, 2012 2:29 pm

Re: Email notifications. Unsupported macro???

Post by stageitp »

Does no one have a clue?

Could it have something to do with rights and or permissions?

"AllowOverride=None"
ExecCGI blah blah...that kind of thing?

I'm running out of options here, and not to forget about hope.
LHammonds
Posts: 23
Joined: Mon Jan 02, 2012 9:03 pm
Location: Behind you!!!

Re: Email notifications. Unsupported macro???

Post by LHammonds »

I'm new to Nagios and slowly setting up a Nagios server to monitor my network. I'm currently writing a plugin to query IBM BladeCenter via SNMP. Quite a chore. I have not delved into notifications yet.

I've been sending various "macros" as input to my scripts and they have been working perfectly.

For troubleshooting, I would recommend creating a debug script. On in which you replace the "sendemail" program with your script in order to see exactly what is being sent to in so you know if it is a nagios problem, configuration problem or a sendemail problem.

Create a "debugsendemail" file and have it parse each parameter passed to it and write the results to a temp file. Create a condition where Nagios would fire off a notification and see what is written to the temp file.

Basically, replace sendemail command with your debug script and see what is being passed to it.

If all the parameters are being written as expected to your temp file, try manually running the sendemail command with the exact output in the temp file. Or better yet, have your debug script create a temp file in such a way that you can run...which will call the sendemail program with all the parameters that was sent to the debug script!!!

LHammonds
stageitp
Posts: 4
Joined: Tue Jan 03, 2012 2:29 pm

Re: Email notifications. Unsupported macro???

Post by stageitp »

Thanks for your reply.

To start with, I didn't script the Sendemail script myself. There was a tutorial on the internet which I followed. Besides that, I unfortunately don't know anything about how to script. So to create a debug script is not an option for me.

Another thing that might be interesting to know is that the macros $USER13$, $USER14$ or $USER15$ work like a charm. When it comes to the macros $ADMINEMAIL$ or $CONTACTEMAIL$...nothing happens. After reading on several websites, I encountered that the macro has to be used different.

When trying the $CONTACTGROUPALIAS$ macro it doesn't work either. Now here's the thing: After the ALIAS, you have to put a contactgroup which is used by Nagios. So that's going to be something like: $CONTACTGROUPALIAS:itp$ (Taking "itp" as a random contactgroup in my Nagios installation).

Result: Still the very same error.

It's like the script demands for an e-mail address, and not some silly macro...
crfriend
Posts: 61
Joined: Thu Sep 01, 2011 7:53 am
Location: Central New England (USA)
Contact:

Re: Email notifications. Unsupported macro???

Post by crfriend »

As a test case for this, what you might try doing is sending the output (including all the macros you wish to test) to a file instead of the program. That'll tell you if they have data in them.

Is the contact actually correctly defined with an e-mail address? If that datum is somehow missing then it'd make sense that the macro would be empty.
Locked