Things To Consider While Configuring Nagios

Posted By : Shiv Pujan Maurya | 27-Dec-2017

Hello friends, It’s been long  we have been using Nagios in home environments. Instead of creating your own script for each service to be monitored on aws servers  it's a good idea to go for nagios. While configuring nagios on aws I faced many issues some were related to security groups and some with email configurations. Let’s begin

 

For installation purpose you can follow any appropiate blog

 

After you are done with installation. Lets resolve issue if any of the following:

Issue -1:  The first issue is that nagios shows that client machine is down. It is due to all inbound traffic is blocked in aws security group. We need to allow the icmp request and reply rules in SG.

 

Allow ICMP traffic in EC2 Security groups:

On Client machine

For icmp

For icmp Go to services > EC2> Security Groups> Inbound >Edit Add new rule > ICMP ipv4 : echo request : IP Address of nagios server For default nrpe port Go to services > EC2> Security Groups> Inbound >Edit Add new rule > custom tcp rule : 5666: IP Address of nagios server If you are looking to monitor tomcat nginx or any other service add rules for them as well.

On Server
Go to services > EC2> Security Groups> Inbound >Edit
Add new rule > ICMP ipv4 : echo reply : IP Address of nagios client

        
Issue 2:  while creating service alert I faced issues with email configurations. “unable to look up public/pickup: No such file or directory”.  

I searched many blogs but no appropriate solution was found.

To solve this simple clean installation of postfix helped me out.

 

Issue -3: I faced another issue with email it was due to nagios not getting exact path of mail package. It was looking at /bin/mail which did not exist on my host.

To solve this updated

notify-host-by-email” and “notify-service-by-email” to /usr/bin/mail

“notify-host-by-email” and “notify-service-by-email”  to /usr/bin/mail

However this path could be found by typing which mail.

 

 

 

Issue -4:  next I did some mis configuration in service mail notification like service notification interval , check freshness , notification period. To solve this I corrected both contacts and host.cfg file

 

In contacts.cfg do

        
“define contact{
       contact_name         nagiosadmin
       use            generic-contact
       alias                        Nagios Admin
       email                       [email protected]
       service_notification_period       24x7                    ; service notifications can be sent anytime
       host_notification_period            24x7                    ; host notifications can be sent anytime
       service_notification_options      w,u,c,r,f,s             ; send notifications for all service states
       host_notification_options       d,u,r,f,s               ; send notifications for all host states
       service_notification_commands   notify-service-by-email ; send notifications via mail
       host_notification_commands      notify-host-by-email
       }”

 

 

 

 

In host ( this is the client file for registered hosts to be monitored)  I defined blocks as following:

“define host {
       use                             linux-server
       host_name                       trade-server
       alias                                 trade-server
       address                         10.40.40.156
       max_check_attempts              5
       check_period                    24x7
       notification_interval           2
      notification_period             24x7
       notifications_enabled        1
       notification_options         d,u,r,f,s
       register                     1
       contact_groups          admins
       contacts                 nagiosadmin
}

# Define a service to check the state of a java1 service
define service{
      use                  generic-service
      host_name            trade-singapore
      service_description  java1
      check_command        check_tcp!9000
      max_check_attempts 2
      check_interval 2
      retry_interval 2
      check_period 24x7
      check_freshness 1

       notification_interval 2
       notification_period 24x7
       notifications_enabled 1
       notification_options         w,u,c,r,f,s
       register                     1
       contact_groups                  admins
       contacts                 nagiosadmin

}
 

 

 

 

 

After you are done with all this just restart the nagios service. This sort of configuration updates did the task for me. May be helpful to you.

 

Thank You for reading my blog.

About Author

Author Image
Shiv Pujan Maurya

Shiv is a Redhat certified engineer with B.Tech in Computer Science & Engineering. He is passionate about new technologies specially in DevOps and Artificial intelligence.

Request for Proposal

Name is required

Comment is required

Sending message..