Nagios Email Notifications not sending emails
Posted: Fri Jan 24, 2020 11:39 am
Hello guys,
I would like to ask you for help with sending e-mail notification from Nagios. I tried to do my best, but I am not able to fix the problem. Nagios doesnt want to send the e-mail notification. I went through this topic: https://support.nagios.com/forum/viewto ... =7&t=39208, but it also didnt fix the issue. Here is my configuration:
Nagios Core: 4.4.5
OS: CentOS 8
kernel: 4.18.0-80.11.2.el8_0.x86_64
SELinux: disabled
cat /usr/local/nagios/etc/nagios.cfg | grep enable_notifications
enable_notifications=1
Configuration files:
/usr/local/nagios/etc/servers/osvobozeni.cfg
/usr/local/nagios/etc/objects/contacts.cfg
/usr/local/nagios/etc/objects/commands.cfg
journalctl log:
### In Nagios web interface: service -> Send custom service notification -> commit
journal -f
### THIS WORKS(from CLI):
Maybe, overlooked something ... but I really can not find out, where I did the mistake. I would appreciate any help.
Thank you very much in advance.
I would like to ask you for help with sending e-mail notification from Nagios. I tried to do my best, but I am not able to fix the problem. Nagios doesnt want to send the e-mail notification. I went through this topic: https://support.nagios.com/forum/viewto ... =7&t=39208, but it also didnt fix the issue. Here is my configuration:
Nagios Core: 4.4.5
OS: CentOS 8
kernel: 4.18.0-80.11.2.el8_0.x86_64
SELinux: disabled
cat /usr/local/nagios/etc/nagios.cfg | grep enable_notifications
enable_notifications=1
Configuration files:
/usr/local/nagios/etc/servers/osvobozeni.cfg
Code: Select all
###
define host {
use linux-server
host_name osvobozeni
alias osvobozeni_RB_Pi
address SERVER_IP_ADDRESS
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
contacts Pavel
}
define service {
use generic-service
host_name osvobozeni
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name osvobozeni
service_description Monitoring web test
check_command check_tcp!8081
contact_groups admins
}
###/usr/local/nagios/etc/objects/contacts.cfg
Code: Select all
###
#### MINE DEFINITION
define contact {
contact_name Pavel
alias polo
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
}
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,Pavel
}
###/usr/local/nagios/etc/objects/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$ **" $CONTACTEMAIL$
}
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$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
###journalctl log:
### In Nagios web interface: service -> Send custom service notification -> commit
journal -f
Code: Select all
Jan 24 17:17:20 monitor nagios[892]: EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;osvobozeni;Monitoring web test;0;Nagios Admin;test mailu
Jan 24 17:17:20 monitor nagios[892]: SERVICE NOTIFICATION: nagiosadmin;osvobozeni;Monitoring web test;CUSTOM (CRITICAL);notify-service-by-email;CRITICAL - Socket timeout;Nagios Admin;test mailu
Jan 24 17:17:20 monitor nagios[892]: SERVICE NOTIFICATION: Pavel;osvobozeni;Monitoring web test;CUSTOM (CRITICAL);notify-service-by-email;CRITICAL - Socket timeout;Nagios Admin;test mailu
Jan 24 17:17:20 monitor nagios[897]: job 1 (pid=1989): read() returned error 11
Jan 24 17:17:20 monitor nagios[895]: job 2 (pid=1990): read() returned error 11
Jan 24 17:17:20 monitor postfix/postdrop[1997]: warning: unable to look up public/pickup: No such file or directory
Jan 24 17:17:20 monitor postfix/postdrop[1998]: warning: unable to look up public/pickup: No such file or directory
### THIS WORKS(from CLI):
Code: Select all
/usr/bin/printf "%b" "test" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" [email protected]Thank you very much in advance.