Page 1 of 1

Modify Nagios Notifications Message

Posted: Tue Jan 08, 2013 4:58 pm
by allamiro
How can I modify nagios notifications to include only the first two octets from the ip address
at those fields
hostname
ipaddress or hostalias

I know commands.cfg has the configurations b ut I m not sure where to look at

Re: Modify Nagios Notifications Message

Posted: Tue Jan 08, 2013 5:23 pm
by abrist
This would require modifying, or writing a completely new notification command.

In commands.cfg you will find:

Code: Select all

# 'notify-host-by-email' command definition
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$
        }
You can use these commands as a template for your desired changes. You may need to write and then call a script to perform your desired actions.