Hello Experts,
I have configured contacts and contact group in Nagios.
I have 2 questions regarding the email.
1. What command does Nagios run for sending the email and where can I find the logs if the email fails? I have postfix enabled on the Nagios server.
2. How can I setup the below scenarios
Suppose I need email every 6 hours if it is warning
or I need email every hour when it is critical
It will be very helpful for me
Thanks
Email configuration for nagios
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Email configuration for nagios
This is defined per contact. In a default Core installation they are defined in the generic-contact template.yunushaikh wrote:1. What command does Nagios run for sending the email and where can I find the logs if the email fails? I have postfix enabled on the Nagios server.
/usr/local/nagios/etc/objects/templates.cfg
Extract:
Code: Select all
name generic-contact ; The name of this contact template
service_notification_commands notify-service-by-email ; send service notifications via email
host_notification_commands notify-host-by-email ; send host notifications via emailCode: Select all
# 'notify-host-by-email' command definition
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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
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" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}There's no real way to have a different notification interval for a warning state and a critical state.yunushaikh wrote:2. How can I setup the below scenarios
Suppose I need email every 6 hours if it is warning
or I need email every hour when it is critical
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
yunushaikh
- Posts: 176
- Joined: Sat Jun 20, 2015 9:04 pm
Re: Email configuration for nagios
If there is no real way to differentiate the notification, then how often will we get emails for warning ( or we dont get email for warning?) and how often we get email for critical.
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Email configuration for nagios
You could do this in some different ways:
1) Have 2 services, one that only notifies on WARNING and one that notifies on CRITICAL
2) Wrap your notification scripts with a time/logic script. You can grab the service state out of the macros and then add your own timing logic.
3) Use 2 contacts/contactgroups and escalations, one contact group only gets the notifications every 6 notification_intervals and that group only receives warning...
None of these fixes are amazing or clean, but there is no built-in way to do what you want.
1) Have 2 services, one that only notifies on WARNING and one that notifies on CRITICAL
2) Wrap your notification scripts with a time/logic script. You can grab the service state out of the macros and then add your own timing logic.
3) Use 2 contacts/contactgroups and escalations, one contact group only gets the notifications every 6 notification_intervals and that group only receives warning...
None of these fixes are amazing or clean, but there is no built-in way to do what you want.
-
yunushaikh
- Posts: 176
- Joined: Sat Jun 20, 2015 9:04 pm
Re: Email configuration for nagios
ok Thanks for you nice suggesstion.
If I configure this way then services will keep on increasing. Will 2 services accept the same command? Nagios should build some option to get this thing with single service. Isnt it?
If I configure this way then services will keep on increasing. Will 2 services accept the same command? Nagios should build some option to get this thing with single service. Isnt it?
-
jdalrymple
- Skynet Drone
- Posts: 2620
- Joined: Wed Feb 11, 2015 1:56 pm
Re: Email configuration for nagios
We add features based upon community interest and the amount of time we have at our disposal. One thing worth noting - it's a community project, the source is open and you're welcome to change the program to fit your needs.yunushaikh wrote:Nagios should build some option to get this thing with single service. Isnt it?
To put in a feature request visit http://tracker.nagios.org
As I mentioned, it's not a clean solution. You can however have duplicate commands. The only parameter that needs to be unique is service_description.yunushaikh wrote:If I configure this way then services will keep on increasing. Will 2 services accept the same command?
-
yunushaikh
- Posts: 176
- Joined: Sat Jun 20, 2015 9:04 pm
Re: Email configuration for nagios
Ok thank you Sir for your help.
It was very helpful.
It was very helpful.