Email notification not working for nely created contacts
Email notification not working for nely created contacts
For newly created contacts email notification is not sending but for already existing contacts email notification is working properly
- tylerhoadley
- Posts: 43
- Joined: Tue Jul 02, 2013 1:41 pm
Re: Email notification not working for nely created contacts
In contact management for the newly created contact. What template is attached?
Can't be 100% sure, but believe the "generic-contact" template should be applied. try that one (remove any others if present ex. "xi_contact_generic) and see if that kicks off the email.
Can't be 100% sure, but believe the "generic-contact" template should be applied. try that one (remove any others if present ex. "xi_contact_generic) and see if that kicks off the email.
Re: Email notification not working for nely created contacts
Thanks @tylerhoadley!
To provide a bit of insight, here's how those two templates work -
When you look at generic-contact, it will use the commands directly linked to it, which are notify-host-by-email and notify-service-by-email. Let's take a look at how these are defined (I will use notify-host-by-email for reference, but the same applies to notify-service-by-email) -
All this script is doing, is printing the data + parsing the variables, and passing it over to /bin/mail which then passes it as a notification.
Now, let's look at xi_contact_generic which is using xi_host_notification_handler and xi_service_notification_handler -
What is important to notice here, is we aren't sending it to another application. The notification will be handled through our internal script, /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php. Here is a broad description of what it does:
- Checks the 'Manage Email Settings' page for your mail settings, if it's sendmail then it will end up sending it out through /bin/mail, and if it's SMTP it will use PHP mailer to send outbound.
- Then, it respects the individual user settings that each XI user has. These can be configured by clicking your logged in username in the top right, and looking at the Notification Preferences, Notification Methods, and Notification Messages page. This was added so that a user can configure their own settings on top of what the global Nagios settings are, without the need to apply configuration.
If a contact is using xi_host_notification_handler, without having a user account created, it will cause issues as it cannot validate against the individual user settings. This is what can cause problems, and in my mind creates the confusion between users <-> contacts.
There is a bit more functionality to it, but I am just writing this to demonstrate the process and help realize why the two are different.
To provide a bit of insight, here's how those two templates work -
Code: Select all
define contact {
name generic-contact
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f,s
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
register 0
}
define contact {
name xi_contact_generic
contactgroups xi_contactgroup_all
host_notification_period xi_timeperiod_24x7
service_notification_period xi_timeperiod_24x7
host_notification_options d,u,r,f,s
service_notification_options w,u,c,r,f,s
host_notification_commands xi_host_notification_handler
service_notification_commands xi_service_notification_handler
register 0
}
Code: Select all
define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\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$
}
Now, let's look at xi_contact_generic which is using xi_host_notification_handler and xi_service_notification_handler -
Code: Select all
define command {
command_name xi_host_notification_handler
command_line /usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=host --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --hostdisplayname="$HOSTDISPLAYNAME$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --datetime="$LONGDATETIME$"
}
- Checks the 'Manage Email Settings' page for your mail settings, if it's sendmail then it will end up sending it out through /bin/mail, and if it's SMTP it will use PHP mailer to send outbound.
- Then, it respects the individual user settings that each XI user has. These can be configured by clicking your logged in username in the top right, and looking at the Notification Preferences, Notification Methods, and Notification Messages page. This was added so that a user can configure their own settings on top of what the global Nagios settings are, without the need to apply configuration.
If a contact is using xi_host_notification_handler, without having a user account created, it will cause issues as it cannot validate against the individual user settings. This is what can cause problems, and in my mind creates the confusion between users <-> contacts.
There is a bit more functionality to it, but I am just writing this to demonstrate the process and help realize why the two are different.
Former Nagios Employee
Re: Email notification not working for nely created contacts
Changed to generic-contact in Manage contact template, but still no luck. One doubt is we need to create Host Notification TimePeriod and Service Notification Time period manually or those will come automatically.
Re: Email notification not working for nely created contacts
Or please send me the steps to create a new contact clearly
Re: Email notification not working for nely created contacts
Do you want to setup a user account that can login to the XI web interface that can receive email notifications or do you want to create a contact only account that cannot login to the XI GUI.
In the XI GUI, can you go to the Admin > Manage Email Settings menu and post what Mail Method you have selected?
What version of XI are you running?
In the XI GUI, can you go to the Admin > Manage Email Settings menu and post what Mail Method you have selected?
What version of XI are you running?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Email notification not working for nely created contacts
No recently i created a service alert, for that i created contact (using one EMail group) to send alert. From newly created contact i am not getting alerts, but if i changed to existing other old contact, i am getting the alert. so please suggest me how to create a new contact with complete steps for the service alert.
Nagios XI version 5.2.0
Nagios XI version 5.2.0
Re: Email notification not working for nely created contacts
Here is a guide you can review for configuring email and text notifications on the XI server.
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Can you post the contact settings for both the working and non-working contact so we can view the settings?
In the XI GUI, can you go to the Admin > Manage Email Settings menu and post what Mail Method you have selected?
https://assets.nagios.com/downloads/nag ... ios-XI.pdf
Can you post the contact settings for both the working and non-working contact so we can view the settings?
In the XI GUI, can you go to the Admin > Manage Email Settings menu and post what Mail Method you have selected?
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Email notification not working for nely created contacts
we are using SMTP Mail Method, the document which you have sent is only for a contact, i need to create a contact for email_group (Distirbution List), alert should go to members of that email group. and already i cross verified the setting configuration of both working and non working contact group.
Re: Email notification not working for nely created contacts
On your email server, do you have a email address that is setup for a distribution list?
If so, then all you have to do is create a User account in the XI GUI by going to the Admin > Manage Users menu, add the User, and fill in that email address for the email address and make sure it is setup and enabled to receive Notifications.
Then you would edit that service in the Core Config Manager and add that user as a contact and then they will receive notification emails for that service.
Does that help out?
If so, then all you have to do is create a User account in the XI GUI by going to the Admin > Manage Users menu, add the User, and fill in that email address for the email address and make sure it is setup and enabled to receive Notifications.
Then you would edit that service in the Core Config Manager and add that user as a contact and then they will receive notification emails for that service.
Does that help out?
Be sure to check out our Knowledgebase for helpful articles and solutions!