Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check_AWS_CloudWatch_metrics

Current Version
6.4.44
Last Release Date
2016-10-29
Compatible With
  • Nagios 3.x
  • Nagios XI
Owner
License
Apache
Hits
157011
Files:
FileDescription
check_cloudwatch_status-6.4.44.rbThe ruby script that retrieve the metric from AWS EC2, ELB or RDS.
check_cloudwatch_status.cfgThe definition of the nagios command.
sample_service.cfgSample of use for retrieving CPU usage of an instance on Amazon EC2.
encrypt_credentials.rbRuby script that encrypts Amazon Web Services Credentials.
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
This is a ruby script that retrieve metrics from Amazon Web Service EC2, ELB or RDS using Amazon CloudWatch API (supports all AWS region).
The Amazon credentials (Access Key ID and Secret Access Key) are read from an encrypted file.

NB: Amazon CloudWatch Namespaces, Dimensions, and Metrics Reference: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html
Using Amazon CloudWatch API, it is possible to retrieve the metrics (CPU, NetWork, Disk) from an instance without installing any agent or configuring SNMP daemon.
Moreover, this requires only read-only credentials that could be easily generated using Amazon IAM. For security reasons, we use encrypted credentials that are decrypted by this plugin.

Here is a command line sample of use for EC2:
debian-secludit # RUBYOPT=rubygems ruby lib/nagios/check_cloudwatch_status.rb -a ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com -i i-XXXXXXXX -f ec2_credentials_1.cfg -C CPUUtilization -c 90 -w 75
CloudWatch Metric: CPUUtilization, Average: 16.81, Maximum: 22.93, Minimum: 11.56|metric_average=16.81 metric_maximum=22.93 metric_minimum=11.56

The ec2_credentials_1.cfg files contains the encrypted credentials as follow:
[blank_space]ec2_access_id[blank_space]B64_encoding(BF-CBC-Cipher_encoding(Access Key ID)
[blank_space]ec2_access_key[blank_space]B64_encoding(BF-CBC-Cipher_encoding(Secret Access Key)
You can use the encrypt_credentials.rb ruby script that does that as follow:
debian-secludit # RUBYOPT=rubygems ruby encrypt_credentials.rb -A XXXXXXXXXXXXXXXXXXXX -S XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -f ec2_credentials.cfg

Here is a sample configuration file for nagios.
define service {
name Amazon_EC2_Instance_Name
use generic-service
check_command check_cloudwatch_status!i-XXXXXXXX!/etc/nagios3/credentials/ec2_credentials_1.cfg!CPUUtilization!50!80
max_check_attempts 3
}

Samples:
- EC2
debian-secludit # RUBYOPT=rubygems ruby lib/nagios/check_cloudwatch_status.rb -a ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com -i i-XXXXXXXX -f ec2_credentials_1.cfg -C CPUUtilization -c 90 -w 75
- RDS
debian-secludit # RUBYOPT=rubygems ruby lib/nagios/check_cloudwatch_status.rb -i RDS_IDENTIFIER -a RDS_IDENTIFIER.XXXXXX.rds.amzonaws.com -f ec2_credentials_1.cfg -D CPUUtilization -c 90 -w 75
- ELB
debian-secludit # RUBYOPT=rubygems ruby lib/nagios/check_cloudwatch_status.rb -i ELB_IDENTIFIER -a ELB_IDENTIFIER.XXXXXX.elb.amzonaws.com -f ec2_credentials_1.cfg -L RequestCount

Requirements:
Ruby version >= 1.8.7
Fog gem version >= 1.25.0
Reviews (29)
bybsilverwood, October 25, 2013
I was able to get this implemented VERY quickly.

My only question is this: How would you set this up if you are using two different regions? I tried just making a second copy of the file, but this appears to not work from within Nagios, though I can run the ruby script from the command line and get proper output.
by5c077yP, October 7, 2013
Hey the plugin is great,
i'm using it for my vpc instances - for the address argument i'm using the aws region and it works perfectly.

Please fix the hard-coded .pem file to be configurable ...
One can create the rsa files via openssl genrsa ...

Thanks a lot
bypsattler22, August 20, 2013
A very useful plug-in that allows us to add CloudWatch metrics to our existing monitoring dashboard.
This is excellent script to monitor EC2 and RDS .The
best feature is we can check free storage space in RDS .
byhyjalsoul, July 29, 2013
1 of 1 people found this review helpful
Need to install amazon-ec2 gem, but other than that, setup is easy and it works great! Very good plugin for nagios to monitor AWS metrics
byMaquis196, July 3, 2013
1 of 1 people found this review helpful
I needed this more for ELB checking then ec2 checking, does the ec2 checking quite well from what I've seen and relatively easy to set up.

However I will ask, is there a way of finegraining elb metrics? At the moment it just uses the entire region, can the -I flag be used for the elb dns entry?

Cheers.
Owner's reply

Hi,

You should be able to check your ELB using the '-L' option that allows to retrieve ELB metrics such as Latency, RequestCount, HealthyHostCount, and UnHealthyHostCount.

If you have problem or need more information, feel free to contact me using "Contact Owner".

Best regards,
Fred

byxoroz, May 27, 2013
1 of 1 people found this review helpful
Could not use the encrypt part
There is a hard code to /etc/cloutomate/cloutomate.pem what is that?
I always get the error:
Exception `NameError' at encrypt_credentials.rb:91 - uninitialized constant Digest::SHA256

Can you help me out?
Owner's reply

Hi Xorox,

The hardcoded file in encrypt_credentials.rb is a file containing a RSA private key in our system.

Could you please send me more information on how you configure the plugin and the full output of the plugin?

Please, feel free to contact me.
Fred

byianmen, December 12, 2012
1 of 1 people found this review helpful
Great plugin. I now can check my amazon instance with nagios ! The ability to see what's going on on all my instances is just great.
bytechlunacy, September 2, 2012
4 of 4 people found this review helpful
just to let people know it needs the amazon-ec2 gem installed to get it working as advertised and a little bit of work done to the rds monitoring to account for api changes
Page 2 of 2