I am using Nagios-3.0b1 i am not able to send email for host down or for services down. Below are my configuration details.
command.cfg
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$" | /bin/mail -s " $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}
contact.cfg
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
contactgroups admins
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,n
host_notification_options d,u,r,f,n
service_notification_commands notify-by-email
host_notification_commands notify-host-by-email
email [email protected]
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
testing.cfg (host file)
define host{
name linux-box1 ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 1
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0
}
define host{
use linux-box1 ; Inherit default values from a template
check_command notify-host-by-email
host_name testing ; The name we’re giving to this server
alias testing ; A longer name for the server
contact_groups admins
address 192.168.1.33 ; IP address of the server
}
nagios.log
[1216278444] HOST NOTIFICATION: nagiosadmin;testing;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (192.168.1.33)
cat /var/log/maillog.log
here sun.abc.net is the host name where nagios is install.
Jul 17 15:31:23 sun sendmail[15230]: m6HA1Mc5015229: to=<[email protected]>, ctladdr=<[email protected]> (502/503),
delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30808, dsn=2.0.0, stat=Sent Jul 17 15:32:12 sun sendmail[15266]: m6HA2CTb015266: from=nagios, size=353, class=0, nrcpts=1, msgid=<200807171002.m6HA2CTb01
[email protected]>, relay=nagios@localhost Jul 17 15:32:12 sun sendmail[15269]: m6HA2CKQ015269: from=[email protected], size=634, class=0, nrcpts=1, msgid=<20080
[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1] (may be forged) Jul 17 15:32:12 sun sendmail[15266]: m6HA2CTb015266: to=nagios@localhost, ctladdr=nagios (502/503), delay=00:00:00, xdelay=00
:00:00, mailer=relay, pri=30353, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (m6HA2CKQ015269 Message accepted for delivery)
cat /var/log/messages
Jul 17 13:07:24 sun nagios: HOST NOTIFICATION: nagiosadmin;testing;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (192.168.1.33)
Jul 17 13:10:18 sun nagios: SERVICE NOTIFICATION: nagiosadmin;rencsc;MG Service check;CRITICAL;notify-service-by-email;(Return code of 127 is out of bounds - plugin may be missing)
nagios.cfg
enable_notifications=1
[email protected]
admin_pager=pagenagios@localhost
If i am firing the below command of command_line manually on linux command prompt than i am getting the mail on my specified email address.
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$ **” [email protected]
Please help me i am new to nagios.
Thanks