I am trying to setup email notifications for more than one contact and cannot seem to get it working. My default setup with a single contact works like a champ so it is an issue with how I am trying to use contact groups I believe.
What I am not clear on is the process how an email for the $CONTACTEMAIL$ Macro used by my email notification comes from. I have two different contacts in my contacts.cfg, who are then assigned to contact groups in my contactgroups.cfg file. From there I have the contact group specified in the services.cfg for the services that I want the other person to receive emails for. Triggering some test alarms yields no emails so I am not sure what is going on.
Any clarification or direction would be appreciated...
$CONTACTEMAIL$ Macro...where does it come from?
-
- Posts: 7698
- Joined: Mon Apr 23, 2012 4:28 pm
- Location: Travelling through time and space...
Re: $CONTACTEMAIL$ Macro...where does it come from?
You should be able to just copy or duplicate your working contact, and change the copy's name and address in the configuration file, then add it to the contact group. That macro pulls the address(s) you give your contacts when setting them up:
http://nagios.sourceforge.net/docs/3_0/ ... ml#contact
http://nagios.sourceforge.net/docs/3_0/ ... ntactgroup
http://nagios.sourceforge.net/docs/3_0/ ... ml#contact
http://nagios.sourceforge.net/docs/3_0/ ... ntactgroup
Re: $CONTACTEMAIL$ Macro...where does it come from?
Agreed...it should be that easy, and this is what I have done, but it is still not working. There is a piece in the chain that is not configured correctly on my part and I am probably not presenting all the information here.slansing wrote:You should be able to just copy or duplicate your working contact, and change the copy's name and address in the configuration file, then add it to the contact group. That macro pulls the address(s) you give your contacts when setting them up:
http://nagios.sourceforge.net/docs/3_0/ ... ml#contact
http://nagios.sourceforge.net/docs/3_0/ ... ntactgroup
My Host check uses the following command: check-host-alive
$USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
Now I am getting emails for this check when it fails. I don't see how since I cannot see where an email address or macro is specified for this check. This part of the reason I am confused but I think I am starting to narrow it down.
Re: $CONTACTEMAIL$ Macro...where does it come from?
The macro is from a contact, which most likely was inherited from a contact group, host, or hostgroup. Can you post the configs for this host, one of its services, both contacts, and the contact group? (obfuscate emails/etc if you wish)ghuey wrote: I don't see how since I cannot see where an email address or macro is specified for this check.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Re: $CONTACTEMAIL$ Macro...where does it come from?
I have butchered these pretty bad in my testing, but here it goes:abrist wrote:The macro is from a contact, which most likely was inherited from a contact group, host, or hostgroup. Can you post the configs for this host, one of its services, both contacts, and the contact group? (obfuscate emails/etc if you wish)ghuey wrote: I don't see how since I cannot see where an email address or macro is specified for this check.
hosts.cfg
Code: Select all
define host {
host_name EXCHANGE
address 172.x.x.x
check_command check-host-alive
notification_interval 15
notification_options d,u,r
max_check_attempts 3
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_period 24x7
notification_period 24x7
contact_groups admins
}
Code: Select all
define service {
service_description Check Openmanage
check_command check_openmanage!172.x.x.x!Slight-NMS
host_name EXCHANGE
check_period 24x7
contact_groups GlenHome,admins
event_handler_enabled 0
max_check_attempts 3
check_interval 5
retry_interval 1
active_checks_enabled 1
passive_checks_enabled 0
notifications_enabled 1
check_freshness 0
freshness_threshold 86400
}
Code: Select all
define contact {
contact_name nagiosadmin
alias Nagios Admin
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
email gsmith@company.com
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
}
define contact {
contact_name glentext
alias Glen Smith
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
email 555555555@vtext.xom
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
}
define contact {
contact_name glengmail
alias Glen Gmail
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
email gsmith@gmail.com
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
}
define contact {
contact_name asmith
alias aaron
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
email asmith@company.com
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
}
define contact {
contact_name chad
alias Chad Smith
host_notification_options d,u,r,f
service_notification_options w,u,c,r,f
email csmith@company.com
host_notification_period 24x7
service_notification_period 24x7
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email
}
Code: Select all
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
define contactgroup {
contactgroup_name GlenHome
alias GlenHome
members glengmail
}
define contactgroup {
contactgroup_name asmithgroup
alias Arron Email
members asmith
}
Code: Select all
notify-host-by-email
/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$
notify-service-by-email <-- This is a custom notification script used, but works fine
/usr/local/nagios/libexec/nagios_send_service_mail.pl \ -H 172.30.1.12 -r $CONTACTEMAIL$ -f html -u
-
- -fno-stack-protector
- Posts: 4366
- Joined: Mon Nov 19, 2012 12:10 pm
Re: $CONTACTEMAIL$ Macro...where does it come from?
the contact email is being pulled in via a path that would look something like: host\service->contact group(admins)->contact(nagiosadmin)->email(gsmith..company.com). When nagios calls the notification command associated with your contact due to an event needing a notification sent, it simply pulls the email address out of the contact information and stores that in the macro structs used for such things.
Is it your gmail contact\address that is not working properly? If so, most likely this is due to either your local mailer, used by notify-host\service-by-email, forwarding directly to your internal server which denies it based on not allowing mail relaying.(perfectly normal and standard setup) It could also be that your ISP is set to deny outbound smtp connections, less likely if you are on a commercial line. Finally it could be that gmail is not allowing you to communicate with them directly, not normally the case if they suspect something is up they usually just put your mail in spam.
With all that, I would look at how your local mailer is setup, such as to forward just to the internal server, and either alter the mail server it is sending to, to allow nagios to relay through it, or correct the local mailer so that it sends to a gmails mail servers if that is the destined domain.
Is it your gmail contact\address that is not working properly? If so, most likely this is due to either your local mailer, used by notify-host\service-by-email, forwarding directly to your internal server which denies it based on not allowing mail relaying.(perfectly normal and standard setup) It could also be that your ISP is set to deny outbound smtp connections, less likely if you are on a commercial line. Finally it could be that gmail is not allowing you to communicate with them directly, not normally the case if they suspect something is up they usually just put your mail in spam.
With all that, I would look at how your local mailer is setup, such as to forward just to the internal server, and either alter the mail server it is sending to, to allow nagios to relay through it, or correct the local mailer so that it sends to a gmails mail servers if that is the destined domain.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.