Nagios Monitoring for AWS EC2 with a Docker Image

To monitor your AWS instances, there are some Docker Images that can be easily installed and provide monitoring Tools such as Nagios, Adagios (Nagios with adanced UI and OK config tools), Grafana, etc…

This post will explain you the concept behind installing a Nagios monitoring tool for AWS EC2 instances with Docker images.

Nagios Dashboard


Nagios Dynamic Hosts map for Hellocloud.ch

As explained in previous post, www.hellocloud.ch is built on AWS with a highly available cloud infrastructure. The CMS WordPress Web application is monitored with Nagios (monitoring Linux hosts only, neither EFS nor Aurora RDS). Thanks to Nagios 4.x, there is a dynamic chart map with online status (green -> means all OK)

How to install Nagios Monitoring with a Docker image

You can find several free Docker containers on Github, just follow the steps and configure on your AWS security groups for the agents instances so that Nagios Server can communicate with your NRPE Agent (Nagios Remote Plugins Executor)

Nagios Server install

After installing Docker and some dependant Pythons Tools, pickup and download one of the Docker images below and

  1. https://github.com/JasonRivers/Docker-Nagios
  2. https://github.com/jsmartin/nagios-docker
  3. https://github.com/ethnchao/docker-nagios
  4. etc..

For new Docker users,  here is a  shortcut tip to enter the container instance (like a nohup) by typing:

$>docker exec -it <containerIdOrName> bash

and to exit the session.

$>exit

At my first beginning stages to use Docker, I was confused not to find the /usr/local/etc/nagios folder with a ls -al after login to my Ubuntu session. You have to remember that Docker runs in a container! and the entry point is to get access into the container instance.

Nagios NRPE agent service install

Hosts states and checks are transmitted between the mai nagios monitoring server host and the “clients” agents with NRPE (Nagios Remote plugins Executor)

Install NRPE

The installation is straight forward by following this guide for Ubuntu 16.04

  1. https://tecadmin.net/install-nrpe-on-ubuntu/

Configure AWS Security groups

In order to allow communication between NRPE (Nagios Remote Plugins Executor) and Nagios monitoring host, the AWS security groups for the agents instances must be configured.

  • Custom TCP, protocol TCP, port 5666, sg-1234xx (launch-wizard-xx), description: nagios NRPE
  • ICMP – IPv4, protocol All, port N/A, sg-1234xx (launch-wizard-xx), description: allow PING

Steps to configure the monitored services (checks)

Finally, at this stage, you can configure your “hoststomonitor.cfg” and restart Nagios Services (SystemCtl or InitD)

Edit your .cfg file directly in vi or nano and restart the Nagios services. Sample extract for check_disk

/usr/local/nagios/etc/services/linux_services.cfg

define service {
  use generic-service
  host_name Intranet
  service_description Disk Usage
  check_command check_nrpe!check_disk
}

With Okconfig, it is also easier to define and configure your service check directly from the web browser

Conclusion

The Journey to install a monitoring system for the EC2 instances touch to his end. To summarize what this post has provided:

  1. Install Docker and pickup some nagios images
  2. Install Nagios Monitoring Server host
  3. Install NRPE agent services on all monitored hosts
  4. Configure AWS Security group to allow communication between Server hosts and NRPE agent (port 566 and ICMP for PING )
  5. Define the monitored services by editing the .cfg file or directly with the tool Okconfig.

! HAPPY MONITORING !

 

One thought on “Nagios Monitoring for AWS EC2 with a Docker Image

Leave a Reply

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