email notification not working on nagios-3.4.4

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

email notification not working on nagios-3.4.4

Post by nagios@ios »

Hello Guys,

i have installed nagios-3.4.4 and nagios-plugiuns-1.4.16. All the features and services are working fine. I configured it for one cisco switch also. The problem is it do not send the alert notification to my email provided in contacts.cfg
Instead they are being saved in /var/spool/mail/root

i am new with linux, but last time i installed nagios-3.2.3 or something the email notifications were working fine.
my contacts.cgf is

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }

thank you in advance.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: email notification not working on nagios-3.4.4

Post by slansing »

Can you show us a service definition with your contact defined for it?
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

Re: email notification not working on nagios-3.4.4

Post by nagios@ios »

Thanks for the reply Slansing..

But i am not sure which file you are asking for?
can you please elaborate a bit..
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: email notification not working on nagios-3.4.4

Post by slansing »

Without anything defined you will not receive any emails, because you are not monitoring anything. The service's would be defined at:

Code: Select all

/usr/local/nagios/etc/services/servicename.cfg
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: email notification not working on nagios-3.4.4

Post by lmiltchev »

You may have something like this:
define service{
use local-service ; Name of service template to use
host_name localhost
service_description PING
check_command check_ping!100.0,20%!500.0,60%
contacts nagiosadmin
}
Also, see if you have anything interesting in the mail log:

Code: Select all

tail /var/log/maillog
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

Re: email notification not working on nagios-3.4.4

Post by nagios@ios »

is this what you ask for ...


define service{
use generic-service ; Inherit values from a template
host_name Outbound-Switch-21 ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

Re: email notification not working on nagios-3.4.4

Post by nagios@ios »

result of maillog..

Feb 6 17:55:11 nagios sendmail[3503]: r16MtBi0003503: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=138426, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r16MtBH1003509 Message accepted for delivery)
Feb 6 17:55:11 nagios sendmail[3510]: r16MtBH1003509: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=138959, dsn=2.0.0, stat=Sent
Feb 6 18:00:12 nagios sendmail[3590]: r16N0C8U003590: from=root, size=426, class=-60, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Feb 6 18:00:12 nagios sendmail[3594]: r16N0CQ6003594: from=<[email protected]>, size=719, class=-60, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 6 18:00:12 nagios sendmail[3590]: r16N0C8U003590: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=138426, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r16N0CQ6003594 Message accepted for delivery)
Feb 6 18:00:12 nagios sendmail[3595]: r16N0CQ6003594: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=138959, dsn=2.0.0, stat=Sent
Feb 6 18:05:11 nagios sendmail[3691]: r16N5B5k003691: from=root, size=426, class=-60, nrcpts=1, msgid=<[email protected]>, relay=root@localhost
Feb 6 18:05:11 nagios sendmail[3697]: r16N5B0k003697: from=<[email protected]>, size=719, class=-60, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Feb 6 18:05:11 nagios sendmail[3691]: r16N5B5k003691: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=138426, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r16N5B0k003697 Message accepted for delivery)
Feb 6 18:05:11 nagios sendmail[3698]: r16N5B0k003697: to=<[email protected]>, ctladdr=<[email protected]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=138959, dsn=2.0.0, stat=Sent
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

Re: email notification not working on nagios-3.4.4

Post by nagios@ios »

please let me know if anyone need more info ..... to have a clear picture
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: email notification not working on nagios-3.4.4

Post by lmiltchev »

Since you don't have the nagiosadmin contact defined in the service definition, nagios will use the contact specified in the generic-service template. Can you show us the generic-service template definition? You will find it in the "templates.cfg":

Code: Select all

vi /usr/local/nagios/etc/objects/templates.cfg
BTW, did you restart nagios after you entered your email in the "contacts.cgf"?
Be sure to check out our Knowledgebase for helpful articles and solutions!
nagios@ios
Posts: 19
Joined: Wed Feb 06, 2013 5:09 pm

Re: email notification not working on nagios-3.4.4

Post by nagios@ios »

@ lmiltchev : thanks for reply.

result of templates.cfg

Define a template for switches that we can reuse
define host{
name generic-switch ; The name of this host template
use generic-host ; Inherit default values from the generic-host template
check_period 24x7 ; By default, switches are monitored round the clock
check_interval 5 ; Switches are checked every 5 minutes
retry_interval 1 ; Schedule host check retries at 1 minute intervals
max_check_attempts 10 ; Check each switch 10 times (max)
check_command check-host-alive ; Default command to check if routers are "alive"
notification_period 24x7 ; Send notifications at any time
notification_interval 30 ; Resend notifications every 30 minutes
notification_options d,r ; Only send notifications for specific host states
contact_groups admins ; Notifications get sent to the admins by default
register 0 ; DONT REGISTER THIS - ITS JUST A TEMPLATE
}
Locked