Alert mail is not getting for a custom service check

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.
Locked
[email protected]
Posts: 3
Joined: Wed Mar 30, 2016 3:48 am

Alert mail is not getting for a custom service check

Post by [email protected] »

HI Support,

I have configured Nagios 4 on CentOS 6.6 64-bit server. And its working properly.
What is my issue is that, I have created a custom service definition for checking a custom service running OR Not. In the webpage, status of that particular service showing correctly. But I didn't getting any alert mail if the service Stopped ( Critical ). So is there any configuration missing for sending alert mail for any custom service.

Version : Nagios Core 4.0.4
OS: CentOS 6.6 64 bit

Checking service definition in Libexec
This is done by creating a simple bash script, which is

#vim /usr/loca/nagios/libexec/check_xxxx

#!/bin/bash
if ps ax | grep -v grep | grep /usr/sbin/XXXXD > /dev/null
then
echo "OK, XXXX service is running"
exit 0
else
echo "CRITICAL , XXXX service is not running"
exit 2
fi



Service definition in localhost.cfg


# vim /usr/local/nagios/etc/objects/localhost.cfg

define service{
use local-service ; Name of service template to use
host_name localhost
service_description XXXX Service
check_command check_xxxx
notifications_enabled 0
}



Command definition in commands.cfg

# vim /usr/local/nagios/etc/objects/commands.cfg
define command{
command_name check_xxxx
command_line $USER1$/check_xxxx -H $HOSTADDRESS$ $ARG1$
}



Kindly check this and advice me, what is the reason for alert mailings is not getting for this custom service check.

Thanks to all in advance.

Regards
Satheesh
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Alert mail is not getting for a custom service check

Post by rkennedy »

You will need to change notifications_enabled from 0, to 1. You'll also need to define a contact like so -

Code: Select all

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 ******
        }
From there, you'll want to add the defined contact to your service definition, and also add notification_options. Here's an example -

Code: Select all

define service{
	host_name		linux-server
	service_description	check-disk-sda1
	check_command		check-disk!/dev/sda1
	max_check_attempts	5
	check_interval	5
	retry_interval	3
	check_period		24x7
	notification_interval	30
	notification_period	24x7
	notification_options	w,c,r
	contacts nagiosadmin
        notifications_enabled 1
	}
Take a look at this link for a more in depth explanation. https://assets.nagios.com/downloads/nag ... tions.html
Former Nagios Employee
[email protected]
Posts: 3
Joined: Wed Mar 30, 2016 3:48 am

Re: Alert mail is not getting for a custom service check

Post by [email protected] »

Thanks rkennedy.....

I have made the changes as per your suggestion. Now its resolved and I am getting the alerts....
Once again thanks... : )(Y)
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Alert mail is not getting for a custom service check

Post by rkennedy »

You're welcome -- glad it worked!

Closing this out now, but feel free to make a new thread if you need any assistance in the future!
Former Nagios Employee
Locked