KMG Group GmbH has developed Nagios Cloudwatch, which is an open source plugin for Nagios and derivates like op5 to monitor Amazon Cloud infrastructure.

Monitoring features:

  • Cost
  • Virtual instances (EC2)
  • Elastic Load Balancers (ELB)
  • Database instnaces (EDB)

Check out the github project page!

To test this out from scratch you will need a monitor server. If you have this, the installation is easy as in:

If you don’t have one already, you can download the latest virtual appliance from OP5 for free at http://www.op5.com/download-op5-monitor/,

Download and unpack the latest stable release of nagios-cloudwatch

1
2
3
4
5
ssh root@your.op5.server
cd /opt/plugins/custom
wget "https://github.com/maglub/nagios-cloudwatch/archive/stable.tar.gz"
tar xvzf stable.tar.gz
ln -s nagios-cloudwatch-stable nagios-cloudwatch

Configure your Amazon AWS credentials in the config.yml file

Add your read-only credentials to Amazon AWS in the config.yml file, both the ACCESS_KEY_ID and the SERET_ACCESS_KEY. Once saved, the check_cloudwatch.rb script is ready for a spin.

cd /opt/plugins/custom/nagios-cloudwatch
cp config.template.yml config.yml
vi config.yml

Test the credentials by listing your EC2 instances:

[root@op5-system nagios-cloudwatch]# ./check_cloudwatch.rb --ec2 --list-instances
Name: vpn-v001ec2 Id: i-91f62199 privateIp: 192.168.99.6 State: Zone: running
Name: kmg-test002ec2 Id: i-7ef62176 privateIp: 192.168.99.10 State: Zone: running
Name: win-test003ec2 Id: i-9956e691 privateIp: 192.168.99.20 State: Zone: stopped
[root@op5-system nagios-cloudwatch]# ./check_cloudwatch.rb --ec2 --instance=i-91f62199 --list-metrics
i-91f62199;DiskReadOps
i-91f62199;StatusCheckFailed_System
i-91f62199;StatusCheckFailed
i-91f62199;DiskWriteOps
i-91f62199;NetworkIn
i-91f62199;CPUUtilization
i-91f62199;NetworkOut
i-91f62199;DiskWriteBytes
i-91f62199;StatusCheckFailed_Instance
i-91f62199;DiskReadBytes
[root@op5-system nagios-cloudwatch]# ./check_cloudwatch.rb --billing
OK - Namespace: Metric: Cost, $10.14 Unit: None (2014-06-18 11:48:00 GMT)
|Maximum=10.140000
[root@op5-system nagios-cloudwatch]# ./check_cloudwatch.rb --billing --ec2
OK - Namespace: AWS/EC2 Metric: Cost, $9.32 Unit: None (2014-06-18 11:48:00 GMT)
|Maximum=9.320000
[root@op5-system nagios-cloudwatch]# ./check_cloudwatch.rb --billing --rds
OK - Namespace: AWS/RDS Metric: Cost, $0.82 Unit: None (2014-06-18 11:48:00 GMT)
|Maximum=0.820000

 

Install the op5 management pack and add hosts to the ec2-instances host group

The configuration of the service checks is made simple in op5 by using a management pack. By installing the management pack, you will get:

  • The checkcommands.cfg configuration for the most common metrics for EC2
  • One host group called ec2-instances
  • 10 pre configured services for the host group (CPUUtilization, DiskReadBytes, DiskReadOps, DiskWriteBytes, DiskWriteOps, NetworkIn, NetworkOut, StatusCheckFailed, StatusCheckFailed_Instance, StatusCheckFailed_System)
  • Any host you configure as a member of the host group ec2-instances will automatically be monitored for these services

To import the management pack for EC2, do the following:

  • Log in to the op5 appliance through the web gui (user: monitor, password: monitor)
  • Go to the “Configure” page and select “Manage management packs”
  • Upload the json file op5/nagios-cloudwatch.op5.management-pack.import.json found in the nagios-cloudwatch directory on your op5 server. You will need a copy of this file on your local computer.
  • Save configuration

Now you are ready to add a couple of AWS instances. What is important to know is that the identifying attributes of an Amazon instance is:

  • Instance ID (i.e. i-123455)
  • Region (i.e. us-west-2)

These two attributes should be added to the host in Nagios as custom attributes for each server:

  • _EC2_ID -> Instance ID
  • _EC2_REGION -> The AWS region in which your instance is created

To do this, you click the “Add custom variable” button in the host configuration view.

host-config-custom-variables

 

A good thing to do in the OP5 environment is to define and save a couple of filters:

  • EC2 Services -> Filter: [services] host.groups >= “ec2-instances”
  • EC2 Servers -> Filter: [hosts] groups >= “ec2-instances”