Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running Nagios 3. It is generating the alerts that are based on my conditions that I had mentioned.

What I want now is to customize my email alerts with a detailed messages. I need to send alerts for my tomcat logs along with the stack trace.

In my commands.cfg file, I have command_line like this :

 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$" | /usr/local/bin/sendEmail -v -f x.x.x.x. -t  x.x.x.x -s smtp.gmail.com:587 -xu x.x.x..x -xp x.x.x.x. -l /var/log/sendEmail -u "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -m "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"

How do I customize it? Where are the variables like $SERVICEOUTPUT$ coming from?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

These variables like $SERVICEOUTPUT$ are coming from the service check that nagios is doing. Other variables like $HOSTADDRESS$ are coming from the host/service definition.

Actually, these are called macros in nagios terms. You can have a look at this page to find the list of macros.

share|improve this answer
    
So typically if I want to return the stack trace of Tomcat in case of an error, how could I do that? –  Ant's Sep 15 '12 at 14:07
    
@Ant's: One possible way is to print the stack trace in the service check script. In this case, you can get the values of $SERVICEOUTPUT$ and $LONGSERVICEOUTPUT$ macros and include these in your email. –  Khaled Sep 15 '12 at 14:21
    
Thanks for the reply. Since I have written the script for it, I will return the stack trace when Nagios find its critical. BTW, where does the macros reside in Ubuntu? Can I be able to add/modify the parameters macros? –  Ant's Sep 15 '12 at 14:25
    
@Ant's: These macros are nagios-related only and have nothing to do with Ubuntu. –  Khaled Sep 15 '12 at 14:30
    
No, what I tried is to ask the location of macros file/directory under Nagios installation. Sorry if my English is bad –  Ant's Sep 15 '12 at 14:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.