Page 1 of 4
How can enable notify via send email
Posted: Sun May 22, 2016 3:22 pm
by baber
Dear all
Hi
I have installed nagios on redhat 6.4 now i have a question i want enable notification alarms via email if a warning or critical appear in nagios it send email to me i have read many documents but clearly in any of them not which service do i have to on my os and where in nagios and os set email config
I want use local email not gmail or yahoo or ....
Warm regards
Babak
Re: How can enable notify via send email
Posted: Mon May 23, 2016 9:38 am
by rkennedy
Take a look at the documentation available on RHEL's site,
https://access.redhat.com/documentation ... tions.html
This provides all of the information necessary to get notifications setup. Let us know if you run into any issues.
Re: How can enable notify via send email
Posted: Tue May 24, 2016 5:25 am
by baber
thanks
but you know better than me for example this path that said in step1 there is not in nagios server (/etc/nagios/gluster/gluster-contacts.cfg) on nagios server we have just one contact.cfg file on this path: /usr/local/nagios/etc/object/ and in this file there is not these configs :
Code: Select all
define contact {
contact_name Contact1
alias ContactNameAlias
email email-address
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 contact {
contact_name Contact2
alias ContactNameAlias2
email email-address
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
}
now can you help me please?
Re: How can enable notify via send email
Posted: Tue May 24, 2016 10:09 am
by rkennedy
Can you post the file /usr/local/nagios/etc/objects/contacts.cfg for us to look at?
Re: How can enable notify via send email
Posted: Tue May 24, 2016 1:56 pm
by baber
rkennedy wrote:Can you post the file /usr/local/nagios/etc/objects/contacts.cfg for us to look at?
i have attached contact.cfg file
warm regards
Babak
Re: How can enable notify via send email
Posted: Tue May 24, 2016 2:25 pm
by rkennedy
Use that file for reference, and you can add your own contact in such as -
Code: Select all
define contact{
contact_name baber ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Baber ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
Then, under your service assign 'baber' as a contact -
Code: Select all
define service {
host_name google.com
service_description HTTP
check_period xi_timeperiod_24x7
check_command check_http
contacts baber
Re: How can enable notify via send email
Posted: Wed May 25, 2016 12:01 am
by baber
rkennedy wrote:Use that file for reference, and you can add your own contact in such as -
Code: Select all
define contact{
contact_name baber ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Baber ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
Then, under your service assign 'baber' as a contact -
Code: Select all
define service {
host_name google.com
service_description HTTP
check_period xi_timeperiod_24x7
check_command check_http
contacts baber
thanks
but it is not working
i have do these steps :
1- edit contact.cfg file and attached that
2-add contacts nagiosadmin line to template.cfg
Code: Select all
define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
check_period 24x7 ; By default, Linux hosts are checked round the clock
check_interval 5 ; Actively check the host every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each Linux host 10 times (max)
check_command check-host-alive ; Default command to check Linux hosts
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 120 ; Resend notifications every 2 hours
notification_options d,u,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
contacts nagiosadmin
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}
3- also add this lione
contacts nagiosadmin
to one of my linux host in .cfg file
Code: Select all
define service{
use local-service
host_name redhat6.4
service_description DNS
check_command check_nrpe!check_dns
contacts nagiosadmin
}
4 - and add contacts nagiosadmin
line to template.cfg attached template.cfg file
5 -in /etc/nagios/objects/commands.cfg file add $NOTIFICATIONCOMMENT$\n after $SERVICEOUTPUT$\n option in notify-service-by-email
Code: Select all
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 $NOTIFICATIONCOMMENT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
it dont work now my dns is in critical but not email send waht is problem?
warm regards
Re: How can enable notify via send email
Posted: Wed May 25, 2016 10:31 am
by rkennedy
Your templateuse local-service does not have any notification_options assigned to it, you will need these in order to have them triggered.
Re: How can enable notify via send email
Posted: Wed May 25, 2016 12:11 pm
by baber
rkennedy wrote:Your templateuse local-service does not have any notification_options assigned to it, you will need these in order to have them triggered.
not working
i have attached all 4 config files
what is my problem ?
Re: How can enable notify via send email
Posted: Wed May 25, 2016 2:05 pm
by rkennedy
Please attach the file /usr/local/nagios/var/objects.cache for us to look at, and let us know which host / service AND contact you're not receiving notifications for.