Not getting any warning mail from nagios

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.
gopukrishnantec
Posts: 19
Joined: Tue Nov 04, 2014 1:49 am

Not getting any warning mail from nagios

Post by gopukrishnantec »

Hi all,

I have started noticing that I am not getting any warning mail from my nagios server. If I send out using the 'Send custom service notification', I can see the mail. So I think there is some configuration issue that is causing this. Can someone please check my configurations below and advise if any changes are required. Also, How can I check when this warning status started logging in ? I have checked /var/log/nagios3/nagios.log but couldn't find any entry related with this.

Code: Select all

/etc/nagios3/servers/Testmachine1.cfg

define service{
        use                             generic-service_gg         ; Name of service template to use
        host_name                       Testmachine1
        service_description             Disk Space
        check_command                   check_nrpe_1arg!check_hda1
#        check_command                   check_all_disks!20%!10%
        }

		
		
		
		
/etc/nagios3/conf.d/g_generic_service.cfg
		
# generic service template definition
define service{
        name                            generic-service_gg ; The 'name' of this service template
        active_checks_enabled           1       ; Active service checks are enabled
        passive_checks_enabled          1       ; Passive service checks are enabled/accepted
        parallelize_check               1       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1       ; We should obsess over this service (if necessary)
        check_freshness                 0       ; Default is to NOT check service 'freshness'
        notifications_enabled           1       ; Service notifications are enabled
        event_handler_enabled           1       ; Service event handler is enabled
        flap_detection_enabled          1       ; Flap detection is enabled
        failure_prediction_enabled      1       ; Failure prediction is enabled
        process_perf_data               1       ; Process performance data
        retain_status_information       1       ; Retain status information across program restarts
        retain_nonstatus_information    1       ; Retain non-status information across program restarts
                notification_interval           60              ; Only send notifications on status change by default.
                is_volatile                     0
                check_period                    24x7
                normal_check_interval           5
                retry_check_interval            1
                max_check_attempts              4
                notification_period             24x7
                notification_options            w,u,c,r,f
                contact_groups                  gmail_group
        register                        0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }

		
		

		
		
vi /etc/nagios3/conf.d/g_contacts.cfg


		define contactgroup{
        contactgroup_name       gmail_group
        alias                   My custom Group
        members                 nagiosuser1,contactg
        }


define contact{
        contact_name                    contactg
        alias                           Root
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f
        host_notification_options       d,r,f
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           myemailaddress1@gmail.com
        }

define contact{
        contact_name                    nagiosuser1
        alias                           Root
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f
        host_notification_options       d,r,f
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           myemailaddress2@gmail.com
        }
Service status showing as warning
Service status showing as warning
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Not getting any warning mail from nagios

Post by Box293 »

Configs do look correct, and because you received the custom notification this proves it at least sends valid messages and your receive them.

Please post the command definition for notify-service-by-email
gopukrishnantec wrote:Also, How can I check when this warning status started logging in ? I have checked /var/log/nagios3/nagios.log but couldn't find any entry related with this.
On your screenshot, in the top left click "View Alert History For This Service"

What version of Nagios running on what Operating System?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
gopukrishnantec
Posts: 19
Joined: Tue Nov 04, 2014 1:49 am

Re: Not getting any warning mail from nagios

Post by gopukrishnantec »

Hi Box293,

Thanks for the reply. See below the command definition :

Code: Select all

# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios alert from tech1 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }
My distributions are as below :

root@test:~# nagios3 -V

Nagios Core 3.5.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL

root@test:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty

Please let me know if any other information needed. I am ready to provide any configurations as I need to find out the actual cause.

Thanks,
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Not getting any warning mail from nagios

Post by jdalrymple »

Check selinux.

"Custom service notification" and routine notifications are handled a bit differently and selinux being enabled can break them one way or the other. Take a peek at that and get back to us. Also, just to be sure test your command right from the command line. Run the simplified version below, replacing only the E-mail address:

Code: Select all

/usr/bin/printf "IT WORKS" | /usr/bin/mail -s "Test E-mail" myemail@example.com
gopukrishnantec
Posts: 19
Joined: Tue Nov 04, 2014 1:49 am

Re: Not getting any warning mail from nagios

Post by gopukrishnantec »

Hi jdalrymple,

Thanks for your reply. I am using ubuntu machine and I read somewhere that we shouldnt use selinux and apparmor together. I have my apparmor enabled already. May be you could see my configurations.

Code: Select all

root@test:~# /etc/init.d/apparmor status
apparmor module is loaded.
5 profiles are loaded.
5 profiles are in enforce mode.
   /sbin/dhclient
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/connman/scripts/dhclient-script
   /usr/sbin/ntpd
   /usr/sbin/tcpdump
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode.
   /usr/sbin/ntpd (1525)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
Also I have tried to send a mail as you suggested and it sent out successfully to my email address:

Code: Select all

root@test:~# su -s /bin/bash nagios
nagios@test:/home/nocme$
nagios@test:/home/nocme$ /usr/bin/printf "IT WORKS" | /usr/bin/mail -s "Test E-mail" myemail@gmail.com
nagios@test:/home/nocme$
please advise
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Not getting any warning mail from nagios

Post by jdalrymple »

I would try to disable apparmor as well and see if that solves your issue. These application protection frameworks do a great job of preventing rogue processes from doing bad things on your system, but similarly they can prevent things we want to happen from occurring. At least as a test disable it, then if that solves your problem you can choose to modify your profiles appropriately to allow Nagios to send mail or leave it off entirely. For RHEL based systems it is our recommendation to leave it off entirely.
gopukrishnantec
Posts: 19
Joined: Tue Nov 04, 2014 1:49 am

Re: Not getting any warning mail from nagios

Post by gopukrishnantec »

Hi all,

I have removed apparmor and still facing the issue. I am still not getting the mails and the whole purpose of monitoring is failed. Any help would be appreciated.

Thanks,
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Not getting any warning mail from nagios

Post by jdalrymple »

gopukrishnantec,

I don't think we ever verified through the GUI whether or not notifications were even "firing" have we? You can just click "Notifications" under "Reports" in the menu pane. Attached is what mine looks like. Please share a screenshot of what yours looks like with us.
Attachments
Clipboard01.jpg
gopukrishnantec
Posts: 19
Joined: Tue Nov 04, 2014 1:49 am

Re: Not getting any warning mail from nagios

Post by gopukrishnantec »

Hi jdalrymple,

I think you are directing me in the correct way. I was able to reproduce the issue again (alerts not coming for certain services) and I can provide you the screenshots as well. In the services, you can see one host is having disk space critical and we haven't received any alert. The interesting thing is I cant see this service in the notifications list you asked me to send. I can see only flapping alert in the notification section for which I am getting the email correctly. So something there wrong with the service definition of this host ? You can see the actual service definitions and notification settings in my first reply to this post. In the host section, you can see the hosts are showing as down since there is no ping to them. Is it causing the services to stop sending the emails ? In that case also, I am getting flapping alerts correctly! Please let me know if you need any information, as I am mad at this issue.

Thanks,
G
Attachments
notifications only listing the flapping and no disk alert came here
notifications only listing the flapping and no disk alert came here
hosts are showing as down since there is no ping to them
hosts are showing as down since there is no ping to them
services showing that disk usage is critical in one of the server
services showing that disk usage is critical in one of the server
Expertise
Posts: 20
Joined: Thu Apr 23, 2015 8:20 am

Re: Not getting any warning mail from nagios

Post by Expertise »

hello look my post i install postfix and i add " -r mail@mail " in command host_by_email and its works fine now

http://support.nagios.com/forum/viewtop ... 0&start=10
Locked