How to email notify?

i just dont know how to do it T_T!
i was searching but i cant find how to do it

i need to make some script or some like that ?

can someone give any simple explain how to do it so i can have an idea
thx

Here’s your documentation, my friend:
nagios.sourceforge.net/docs/2_0/ … tions.html

In the misccommands.cfg example you should have some sections like:

‘notify-by-email’ command definition

define command{
command_name notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHos
t: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr
/bin/mail -s "
$NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

Which basically just prints some variables and pipes them into the /usr/bin/mail command. Make sure that misccommands.cfg is included in your nagios.cfg :
cfg_file=/usr/local/nagios/etc/misccommands.cfg

You will next need to add your email address to a contact{}, which has ‘service_notification_commands’ set to ‘notify-by-email’ :

define contact{
contact_name mike
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email [email protected]
}

Next, you have to define a contactgroup{} that points at that contact:

define contactgroup{
contactgroup_name level_1_techies
alias Nagios Administrators
members mike
}

Finally, you can point a host{} or service{} entry at that contactgroup{}, using the ‘contact_groups’ key:

define host{
use generic-host ; Name of host template to use
host_name localhost
alias localhost
address 127.0.0.1
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,r
contact_groups level_1_techies
}

You should probably also check that your command-line /usr/bin/mail is working and can send email out, just type ‘/usr/bin/mail [email protected]’ at a command line, enter a subject, then type some text, and end by typing a period ‘.’ by itself on a blank line. See if you get the email.

Hope this helps!

-mike

should all this fail try the xmail command… (at least on solaris this works instead of mail)

Luca