Command.cfg

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
Bevlar
Posts: 3
Joined: Fri Oct 21, 2011 3:48 am

Command.cfg

Post by Bevlar »

Hi,

I would like add all of the information from the Nagios alert email to the end of the message in .csv format eg:


***** Nagios *****

Notification Type: PROBLEM

Service: Port 13 B/W Usage - Sage
Host: Conquest PowerConnect 2
Address: 172.x.x.x
State: WARNING

Date/Time: Mon Feb 20 08:54:14 GMT 2012

Additional Info:

Traffic WARNING - Avg. In = 614.2 KB/s, Avg. Out = 5.0 MB/s

PROBLEM,Port 13 B/W Usage - Sage,Conquest PowerConnect 2,172.x.x.x,WARNING,Mon Feb 20 08:54:14 GMT 2012

Is this possible?

Thanks
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Command.cfg

Post by agriffin »

You will want to modify your notification commands to include the desired information. They are probably named notify-host-by-email and notify-service-by-email. By default they look like this:

Code: Select all

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$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Notice that the definition includes the body of the email with some placeholders like $SERVICEDESC$ (also, in case you're not a programmer you should know that '\n' means a new line). These are automatically replaced by appropriate values by nagios. You can find the full list here. Simply edit the command to include what you want.
Locked