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

The default format for alert messages is:

** RECOVERY Host Alert: server is UP **
***** Nagios *****

Notification Type: RECOVERY
Host: server
State: UP
Address: server.ru
Info: PING OK - Packet loss = 0%, RTA = 26.00 ms

Date/Time: Thu Aug 13 17:08:16 MSD 2009

I want maximum information in minimum letters. First, to be able to get information from SMS. Second, to read only the headers of e-mail messages in 90% cases.

For example, the previous message can be just "H: server is UP" where H stands for Host Alert. If this server is down, I would like to get such a message: [!] H: server is DOWN.

Instead of message, that "Swap usage on server is CRITICAL" I would like to get "[!] S: server/swap usage is >50%" where 50 was taken from the nagios config for check_swap, not hardcoded into the message.

And if "Router/wan2 is CRITICAL", I want to see "ADSL channel is off".

So, to summarize, I want to customize message for every service and its state separately, with ability to use plugin parameters in text.

How can I achieve this?

share|improve this question

3 Answers 3

Nagios can be configured to send notifications by various ways and in various formats. If you need to personalize that please refer to your commands.cfs.
This is an example to show you how to receive a short notification by sms using gnokii:


define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%.120s" "$HOSTALIAS$ is $HOSTSTATE$" |/usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r
        }

define command{ command_name notify-service-by-sms command_line /usr/bin/printf "%.120s" "$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" | /usr/local/bin/gnokii --sendsms $CONTACTPAGER$ -r }

The output is like this "hostname is up"

share|improve this answer
    
Agreed. This is your bible: nagios.sourceforge.net/docs/3_0/objectdefinitions.html –  Matt Simmons Aug 13 '09 at 15:31
    
Dammit ... Matt beat me again. Learn and love your macros. –  breadly Aug 13 '09 at 15:41
    
bread555: The only reason I won this time is because I never close that tab ;-) I should print it out and have it laminated and bound. –  Matt Simmons Aug 13 '09 at 15:47
1  
LOL. I did. Printed the whole damn manual, then reprinted the macro pages laminated them and put them over my desk. –  breadly Aug 13 '09 at 16:07
    
You win :-) Very nice! –  Matt Simmons Aug 13 '09 at 16:38

There are several aggregate addons for nagios that, in addition to allowing you to specify shorter alerts, will combine several alerts into 1 page, so that you don't get paged 200 times when lots of things go down at once.

Two good ones are:

  • nan (This runs as a daemon)
  • nans (This runs via cron. Don't be fooled by the 'Netsaint' in the name - it works very well with current versions of nagios)

Alerts look something like this from nans (but can be customized of course)

CRITICAL pages: 2 hostname.example.com - WWW is CRITICAL - Thu Aug 13 11:00:00 EDT 2009 | hostname.example.com - SSL is CRITICAL - Thu Aug 13 11:00:01 EDT 2009
share|improve this answer
    
<P:2 R:1 A:1> P: host1/HTTP,FTP CRIT - R: host2/FTP OK - A: host3/SMTP WARN 2004-07-15 14:12:43 - this is more closer to what I want. But nan is accumulating alerts and I want them be sent immediately as the problem happens. And it still uses one command template for all notifications. –  lexsys Aug 14 '09 at 6:50

Also, if you need more flexibility, think of putting a bash script in between nagios and you. This can let you send out messages with greater flexibility, for example you don't want recovery emails sent to your automated ticket creator.

share|improve this answer
    
I've always thought it would be very cool to develop a program that would listen to replies to the nagios messages, so if I was at my phone, I could reply with "ACK" and it would switch the state to "acknowledged". Know of anything like that? –  Matt Simmons Aug 13 '09 at 15:48
    
I got scared off by the Turing Test requirements and just hired a 24/7 NOC instead. –  breadly Aug 13 '09 at 16:09

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.