Properly setting email notifications for contacts.
Posted: Tue Feb 22, 2022 9:34 am
Hi all!
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.
This seems to be working just fine. I had to do some tweaking on the mailserver but I have tested this by just running the command in command line ( filling in some details ). It worked as I expected.
Where my problem lies is correct contact settings ? I guess.
say I have following host:
where use akro-server is:
with contact_groups admins and contacts fsit being:
when this host goes down I'm not receiving any emails. Same goes for the services added to this host.
Can anyone tell me how to setup mail notifications properly ? Or tell me what am I doing wrong ?
Thank you all kindly.
Joe
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="[email protected]( 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 [email protected]
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