25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Nagios email notification configuration – How we do it!!

by | Feb 15, 2020

Want to configure email notification in Nagios? We can help you do it.

Enabling an email notification in Nagios will help us to get the notification instantly when the server goes down.

At Bobcares, we often receive requests regarding Nagios as a part of our Server Management Services.

Today, let’s see how our Support Engineers set up email alerts in Nagios for our customers.

 

Nagios email notification

Nagios is an open source monitoring tool. It provides both notification and alert system. Monitoring the Nagios interface will not be feasible all the time. That’s where the email notification helps. With an email option, it can send an email to a contact or a group of contacts during any events.

However, to set up email notification for a user, we need to define in Nagios Object Contact configuration file. Usually, the file will be present in the Nagios folder as contacts.cfg.

Let us discuss how our Support Engineers setup mail notification in Nagios.

 

Email notification configuration in Nagios

Recently, one of the customers contacted us to set up email notification in his Nagios. Let us discuss how our Support Engineers set it up for our customers.

First, we log in to the Nagios server.

Then we stop Nagios service using the command

service nagios stop

Now we locate the contacts.cfg file. The file will be based on the Nagios configuration.

The default location of the contacts.cfg will be at

/usr/local/nagios/etc/objects/contacts.cfg

We edit the contact_name, alias, and email in the configuration file under the define contact section.

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

The service_notification_options help us define the service states for which the notification needs to be sent out to the contact email.

The w option notifies the warning service states, u for the unknown service states and c notify the critical service states and so on.

We use the host_notification_options to define the host state for which notifications need to be sent.

The d notify the down host state and u notify the unreachable state and so on.

Now we need to add the details regarding the mail group to send the email.

define contactgroup{
contactgroup_name Group1
alias GroupAlias
members Contact1,Contact2
}

Then in the template.cfg file at the Nagios location, we specify the contact name and contact group name.

We also specify the notification for individual service editing the parameter define service.

Then we edit the command.cfg file and add $NOTIFICATIONCOMMENT$\n after the $SERVICEOUTPUT$\n option. We add the below details in the file.

# '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 $NOTIFICATIONCOMMENT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

Finally, we start the Nagios service using the command

service nagios start

That’s it and you will get email alerts on events related to the server.

[Trouble enabling email notifications in Nagios? We are available 24×7 to help.]

 

Conclusion

In this write-up, we have discussed the details on how our Support Engineers do the Nagios email notification configuration.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF