I've recently started using Nagios Core for my monitoring purposes and right now I'm struggling with proper setup of contacts and / or notifications for contact.
I do have a mailserver already present in my network so I didn't install new one on the Nagios machine ( Postfix, etc ... ).
What I did instead is edited the "notify-host-by-email" command in commands.cfg.
Code: Select all
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" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -S smtp="smtp://<myMailServerIP>" -S from="my@email.com( Nagios )" $CONTACTEMAIL$
}
Where my problem lies is correct contact settings ? I guess.
say I have following host:
Code: Select all
define host {
host_name akro-200
parents akro-gw
use akro-server
alias Akropolis DC
address <IP>
hostgroups akro-servers
_PORT <PORT>
_TOKEN <NCPATOKEN>
}
Code: Select all
define host {
name akro-server
use generic-host
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive-p
contact_groups admins
contacts fsit
hostgroups akro-servers
register 0
}
Code: Select all
define contact {
contact_name fsit
alias fsit
email myEmail@address.com
service_notification_period 24x7
service_notification_options w,u,c,r,f,s
service_notification_commands notify-service-by-email
host_notification_period 24x7
host_notification_options d,u,r,f,s
host_notification_commands notify-host-by-email
}
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members fsit
}
Can anyone tell me how to setup mail notifications properly ? Or tell me what am I doing wrong ?
Thank you all kindly.
Joe