My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
04  
Chapter 4: Amazon AWS EC2 Plugin
Updated Apr 17, 2011 by jayeshst...@gmail.com

Amzon EC2 Plugin

Overview

The Amazon EC2 Plugin can be used to monitor your EC2 instances, Elastic IPs, EBS volumes, snapshots and AMI images on Amazon's AWS Cloud. The plugin monitors the counts and state of your EC2 resources by querying the Amazon AWS API as well as keeps an eye on the Spot prices of EC2 instances. Because the plugin checks the status of your resources using the AWS API, no software or agent needs to be installed on your EC2 instances. Thus anytime you instantiate an EC2 instance, it is automatically "covered and monitored" by the plugin.

Setup and Configuration

The Amazon EC2 plugin uses AWS REST API and does not require the AWS SDK. However it uses PHP and does need the following packages:

  • php5-dev (or php5-devel) = Files for PHP5 module development
  • php5-pear = PEAR - PHP Extension and Application Repository
  • gcc = GNU C Compiler
  • make = make utility
  • php5-hash = PHP hashing functions

To install the above on a Zabbix appliance, login into the appliance as root (default password = zabbix) and run the following commands:

  • yast -i php5-devel
  • yast -i gcc
  • yast -i php5-pear
  • yast -i make
  • yast -i php5-hash

Next download the Amazon EC2 Plugin shell script and php file from http://mikoomi.googlecode.com/svn/plugins/ and copy them into /etc/zabbix/externalscripts directory on the Zabbix server. Make sure that the php script and shell script are made executable.

Next open up a browser and download the MongoDB Zabbix template. Now login to the Zabbix frontend (user = admin, password = zabbix).

Navigate as follows:

  • Configuration >> Templates
  • Click on the "Import Template" button on the top right-hand corner
  • In the "Import file" dialog box, browse/search/enter the filename of the Zabbix template that was downloaded
  • Upload the template

Now you are ready to start monitoring your Amazon Cloud instances, images, volumes, snapshots and elastic IPs!

Monitoring Your Amazon AWS Cloud Resources

Follow these steps to start monitoring:

  • login to the Zabbix front-end and navigate to Configuration >> Hosts
  • Click on Create Host button on the top right-hand corner.
  • Fill in the details - where Name = your choice of name for collection of Amazon AWS EC2 resources to be monitored
  • Next click on the Add button in the Linked templates section of the screen.
  • You will see a list of templates - select the template Template_Amazon_AWS_EC2

In the Macros section, add the following three macros -

  • {$AWS_ACCOUNT}
  • {$AWS_ACCOUNT_ACCESS_KEY}
  • {$AWS_ACCOUNT_SECRET_KEY}

The value for {$AWS_ACCOUNT} should be your Amazon EC2 account id. The value for {$AWS_ACCOUNT_ACCESS_KEY} should be your AWS account access key and the value for {$AWS_ACCOUNT_SECRET_KEY} should be the account access secret key. Note that you can get this informaton by logging into Amazon AWS and clicking on Account and then Security Credentials.

Monitored Metrics

The Amazon EC2 plugin monitors the following metrics or items during each cycle:

  • Total non-public AMI images
  • Total public AMI images
  • Total AMI images
  • EC2 Instances - Total with monitoring disabled
  • EC2 Instances - Total with monitoring disabling
  • EC2 Instances - Total with monitoring enabled
  • EC2 Instances - Total with monitoring pending
  • EC2 Instances - Total in pending state
  • EC2 Instances - Total unavailable due to InstanceInitiatedShutdown
  • EC2 Instances - Total unavailable due to InternalError (internal to instance)
  • EC2 Instances - Total unavailable due to InvalidSnapshot
  • EC2 Instances - Total unavailable due to UserInitiatedShutdown
  • EC2 Instances - Total unavailable due to VolumeLimitExceeded
  • EC2 Instances - Total unavailable due to InsufficientInstanceCapacity
  • EC2 Instances - Total unavailable due to InternalError
  • EC2 Instances - Total unavailable due to SpotInstanceTermination
  • EC2 Instances - Total in running state
  • EC2 Instances - Total in shutting-down state
  • EC2 Instances - Total in stopped state
  • EC2 Instances - Total in stopping state
  • EC2 Instances - Total in terminated state
  • EC2 Instances - Total of type c1.medium
  • EC2 Instances - Total of type c1.xlarge
  • EC2 Instances - Total of type cc1.4xlarge
  • EC2 Instances - Total of type cg1.4xlarge
  • EC2 Instances - Total of type m1.large
  • EC2 Instances - Total of type m1.medium
  • EC2 Instances - Total of type m1.small
  • EC2 Instances - Total of type m1.xlarge
  • EC2 Instances - Total of type m2.2xlarge
  • EC2 Instances - Total of type m2.4xlarge
  • EC2 Instances - Total of type m2.xlarge
  • EC2 Instances - Total of type t1.micro
  • EC2 Instances - Total without monitoring
  • EC2 Elastic IP Addresses - Total assigned to instances
  • EC2 Elastic IP Addresses - Total
  • EC2 Elastic IP Addresses - Total unassigned/free
  • EC2 Reserved Instances - Total
  • EC2 Reserved Instances - Total of type c1.medium
  • EC2 Reserved Instances - Total of type c1.xlarge
  • EC2 Reserved Instances - Total of type m1.large
  • EC2 Reserved Instances - Total of type m1.medium
  • EC2 Reserved Instances - Total of type m1.small
  • EC2 Reserved Instances - Total of type m2.2xlarge
  • EC2 Reserved Instances - Total of type m2.4xlarge
  • EC2 Reserved Instances - Total of type other
  • EC2 Snapshots - Total Size GB
  • EC2 Snapshots - Total in status completed
  • EC2 Snapshots - Total in status error
  • EC2 Snapshots - Total in status pending
  • EC2 Snapshots - Total
  • EC2 Snapshots (Amazon-owned) - Total size GB
  • EC2 Snapshots (Amazon-owned) - Total in status completed
  • EC2 Snapshots (Amazon-owned) - Total in status error
  • EC2 Snapshots (Amazon-owned) - Total in status pending
  • EC2 Snapshots (Amazon-owned) - Total
  • EC2 Snapshots (owned by others) - Total size GB
  • EC2 Snapshots (owned by others) - Total in status completed
  • EC2 Snapshots (owned by others) - Total in status error
  • EC2 Snapshots (owned by others) - Total in status pending
  • EC2 Snapshots (owned by others) - Total
  • EC2 Snapshots (self-owned) - Total size GB
  • EC2 Snapshots (self-owned) - Total in status completed
  • EC2 Snapshots (self-owned) - Total in status error
  • EC2 Snapshots (self-owned) - Total in status pending
  • EC2 Snapshots (self-owned) - Total
  • EC2 Spot Price - for c1.mediumLinux_UNIX
  • EC2 Spot Price - for c1.mediumWindows
  • EC2 Spot Price - for c1.xlargeLinux_UNIX
  • EC2 Spot Price - for c1.xlargeWindows
  • EC2 Spot Price - for cg1.4xlargeLinux_UNIX
  • EC2 Spot Price - for cc1.4xlargeLinux_UNIX
  • EC2 Spot Price - for m1.largeLinux
  • EC2 Spot Price - for m1.largeWindows
  • EC2 Spot Price - for m1.smallLinux_UNIX
  • EC2 Spot Price - for m1.smallWindows
  • EC2 Spot Price - for m1.xlargeLinux_UNIX
  • EC2 Spot Price - for m1.xlargeWindows
  • EC2 Spot Price - for m2.2xlargeLinux_UNIX
  • EC2 Spot Price - for m2.2xlargeWindows
  • EC2 Spot Price - for m2.4xlargeLinux_UNIX
  • EC2 Spot Price - for m2.4xlargeWindows
  • EC2 Spot Price - for m2.xlargeLinux_UNIX
  • EC2 Spot Price - for m2.xlargeWindows
  • EC2 Spot Price - for t1.microLinux_UNIX
  • EC2 Spot Price - for t1.microWindows
  • EC2 Spot Price - for t1.microSUSE_Linux
  • EC2 Spot Price - for cc1.4xlargeSUSE_Linux
  • EC2 Spot Price - for m2.xlargeSUSE_Linux
  • EC2 Spot Price - for m1.smallSUSE_Linux
  • EC2 Spot Price - for 4xlargeSUSE_Linux
  • EC2 Spot Price - for m1.xlargeSUSE_Linux
  • EC2 Spot Price - for c1.mediumSUSE_Linux
  • EC2 Spot Price - for m1.largeSUSE_Linux
  • EC2 Spot Price - for cg1.4xlargeSUSE_Linux
  • EC2 Spot Price - for m2.2xlargeSUSE_Linux
  • EC2 Spot Price - for c1.xlargeSUSE_Linux
  • EC2 Volumes - Total in attached state
  • EC2 Volumes - Total size (GB) of volumes in attached state
  • EC2 Volumes - Total in attaching state
  • EC2 Volumes - Total size (GB) of volumes in attaching state
  • EC2 Volumes - Total in detached state
  • EC2 Volumes - Total size (GB) of volumes in detached state
  • EC2 Volumes - Total in detaching state
  • EC2 Volumes - Total size (GB) of volumes in detaching state
  • EC2 Volumes - Total in status available
  • EC2 Volumes - Total size (GB) of volumes in status available
  • EC2 Volumes - Total in status creating
  • EC2 Volumes - Total size (GB) of volumes in status creating
  • EC2 Volumes - Total in status other
  • EC2 Volumes - Total size (GB) of volumes in status other

Pre-canned Triggers

Triggers in Zabbix are events of interest that happen with respect to the monitored metrics. For example, the plugin keeps track of the total number of instances. If this count changes, it flags this event by firing a trigger. You can choose to ignore this trigger or you can choose to take an action - e.g. send an email or run a shell script.

The Amazon EC2 plugin comes with the following built-in triggers:

  • No data received from EC2 overview plugin in the last 15 minutes
  • The number of running instances has increased
  • The number of running instances has decreased
  • The total number of running instances has decreased
  • The total number of running instances has increased
  • The total number of instances has increased
  • The total number of instances has decreased
  • The number of elastic IP addresss has increased
  • The number of elastic IP addresses has decreased
  • The number of reserved instances has increased
  • The number of reserved instances has decreased
  • One or more snapshots were successfully completed
  • A new snapshot has been created
  • One or more snapshots had errors
  • The number of self-owned snapshots has increased
  • The number of self-owned snapshots has decreased
  • The number of spot instances has increased
  • The number of spot instances has decreased
  • One or more volumes have been attached to instances
  • One or more volumes have been detached from instances
  • The number of available volumes has increased
  • The number of available volumes has decreased

Comment by j...@jlmarcotte.com, Aug 18, 2011

This is Fantastic. However I have found issue I have not been able to overcome. The Total Number of EC2 Instances. I get a Report of 1 instead of my actual number. The only thing that I can think of is that I only have 1 instance that displays a platform. All except 1 are Ubuntu images. Any Ideas how to correct this? Thanks again. This is great

Comment by ryan.tay...@gmail.com, Nov 16, 2011

You have stated: Next open up a browser and download the MongoDB Zabbix template. Now login to the Zabbix frontend (user = admin, password = zabbix).

I believe you meant to say Template_Mikoomi_Amazon?_AWS_EC2 template

Comment by ryan.tay...@gmail.com, Nov 16, 2011

Please help me configure this properly. The Account Name you specify above, is it a # or a username? I am not getting anything from this monitor with the exception of No data received from EC2 overview plugin in the last 15 minutes.

If you can help me I would appreciate it very much, rtaylor@taser.com

Comment by ryan.tay...@gmail.com, Nov 16, 2011

823:20111116:232419.556 Item AWS EC2:mikoomi-aws-ec2-overview-plugin.sh[ -a {$AWS_ACCOUNT} -k {$AWS_ACCOUNT_ACCESS_KEY} -s {$AWS_ACCOUNT_SECRET_KEY} -z {HOSTNAME}?] is not supported is what I am seeing in the logs

Comment by project member jayeshst...@gmail.com, Nov 17, 2011

Hi Ryan,

I just tried out the plugin (I had released a long time ago ;-) - and it worked fine for me.

Can you tell me what is your Zabbix platform? Are you using the Zabbix appliance or are you using your own build of Zabbix? It doesn't matter as such as I have had people use it on their own existing builds of Zabbix.

Next make sure that you have followed all the pre-requisite steps for php

The Amazon EC2 plugin uses AWS REST API and does not require the AWS SDK. However it uses PHP and does need the following packages:

  • php5-dev (or php5-devel) = Files for PHP5 module development
  • php5-pear = PEAR - PHP Extension and Application Repository
  • gcc = GNU C Compiler
  • make = make utility
  • php5-hash = PHP hashing functions

To install the above on a Zabbix appliance, login into the appliance as root (default password = zabbix) and run the following commands:

  • yast -i php5-devel
  • yast -i gcc
  • yast -i php5-pear
  • yast -i make
  • yast -i php5-hash

Also follow the instructions on http://code.google.com/p/mikoomi/wiki/04 to setup/configure the template.

Also make sure that the script mikoomi-aws-ec2-overview-plugin.sh is executable. Change directory to the location of the script (e.g. /etc/zabbix/externalscripts in my case).

Now test the script as follows (type in literally like this!) -

./mikoomi-aws-ec2-overview-plugin.sh junk -d -a 5604-3945-9876 -k 05X5LK08YDG4HHBHB9F82 -s qhYZioRoSWYTQHfJDNLHN5H8/xA+6m2rc8lg83zl -z aaa

You will not see any message/output, but you can check the output in /tmp as follows -

linux-epfq:/etc/zabbix/externalscripts # more /tmp/mikoomi-aws-ec2-overview-plugin.php_aaa.log

mikoomi-aws-ec2-overview-plugin.php Version 1.3

/etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:exec_ec2_query:185:HTTP request sent to EC2 for DescribeImages? = https://ec2.amazonaws.com/?AWSAccessKeyId =05X5LK08YDG4HHBHB9F82&Action=DescribeImages?&Owner=self&SignatureMethod?=HmacSHA256&SignatureVersion?=2&Timestamp=2011-11-18T02%3A23%3A54Z&Version=2010-06-15&Signature=CB1l MkKbc1cClUVL1EWsBqMNfxZJsIBaG%2FnQpj6cQvI%3D Error: HTTP result from EC2 was either null/empty or errors encountered

HTTP Result :

This output shows that the script was able to successfully communicate with AWS but encountered application error.

Next get access to your AWS Account-id, AWS Access Key-Id and AWS Secret-Access-Key.

Rerun the script as follows -

./mikoomi-aws-ec2-overview-plugin.sh junk -d -a <AWS Account-Id> -k <AWS Access Key> -s <AWS Secret-Access-Key> -z aaa

Now examine the output as follows

linux-epfq:/etc/zabbix/externalscripts # more /tmp/mikoomi-aws-ec2-overview-plugin.php_aaa.log

You should see something like this -

mikoomi-aws-ec2-overview-plugin.php Version 1.3

/etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:exec_ec2_query:185:HTTP request sent to EC2 for DescribeImages? = https://ec2.amazonaws.com/?AWSAccessKeyId =05X50Q8YDG4HHBHB9F82&Action=DescribeImages?&Owner=self&SignatureMethod?=HmacSHA256&SignatureVersion?=2&Timestamp=2011-11-18T02%3A32%3A46Z&Version=2010-06-15&Signature=LuIAZ %2FnR1WWEvcUebsmXbIj3smNiVazIwZXEjRuvipw%3D /etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:EC2_DescribeImages?:228:HTTP result received from EC2 for DescribeImages? = SimpleXMLElement::set_state(ar ray(

'requestId' => '8d2e8411-dd88-42ec-936a-02216ac37d5b', 'imagesSet' =>
SimpleXMLElement::set_state(array( )),
)) /etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:exec_ec2_query:185:HTTP request sent to EC2 for DescribeInstances? = https://ec2.amazonaws.com/?AWSAccessKe yId=05X50Q8YDG4HHBHB9F82&Action=DescribeInstances?&SignatureMethod?=HmacSHA256&SignatureVersion?=2&Timestamp=2011-11-18T02%3A32%3A46Z&Version=2010-06-15&Signature=tvckNFSLCU yu6Rbazy%2FZO11LKsey8lbpB11mXgcfR%2FY%3D /etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:EC2_DescribeInstances?:270:HTTP result received from AWS for DescribeInstances? = SimpleXMLElement::set_st ate(array(
'requestId' => 'e1bdfa0f-b544-49eb-a075-299dcee1b97b', 'reservationSet' =>
SimpleXMLElement::set_state(array( )),
)) /etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:exec_ec2_query:185:HTTP request sent to EC2 for DescribeAddresses? = https://ec2.amazonaws.com/?AWSAccessKe yId=05X50Q8YDG4HHBHB9F82&Action=DescribeAddresses?&SignatureMethod?=HmacSHA256&SignatureVersion?=2&Timestamp=2011-11-18T02%3A32%3A47Z&Version=2010-06-15&Signature=MeOgBfOlcq? omOqlXg5e6dqRTjt3s4g4DWQIQsfJujkE%3D /etc/zabbix/externalscripts/mikoomi-aws-ec2-overview-plugin.php:EC2_DescribeAddresses?:443:HTTP result received from EC2 for DescribeAddresses? = SimpleXMLElement::set_st ate(array(
'requestId' => '7f44646a-4fb1-4f71-8241-703c4e5008fd', 'addressesSet' =>
SimpleXMLElement::set_state(array( )),

If this works, then the script is working fine.

Now ensure that you have configured the EC2 account (or host as Zabbix calls it) in the front-end correctly.

See the instructions below -

Monitoring Your Amazon AWS Cloud Resources Follow these steps to start monitoring:

  • login to the Zabbix front-end and navigate to Configuration >> Hosts
  • Click on Create Host button on the top right-hand corner.
  • Fill in the details - where Name = your choice of name for collection of Amazon AWS EC2 resources to be monitored
  • Next click on the Add button in the Linked templates section of the screen.
  • You will see a list of templates - select the template Template_Amazon?_AWS_EC2

In the Macros section, add the following three macros -

  • {$AWS_ACCOUNT}
  • {$AWS_ACCOUNT_ACCESS_KEY}
  • {$AWS_ACCOUNT_SECRET_KEY}

The value for {$AWS_ACCOUNT} should be your Amazon EC2 account id. The value for {$AWS_ACCOUNT_ACCESS_KEY} should be your AWS account access key and the value for {$AWS_ACCOUNT_SECRET_KEY} should be the account access secret key. Note that you can get this informaton by logging into Amazon AWS and clicking on Account and then Security Credentials.

Hope this resolves your problem.....

-- Jayesh


Sign in to add a comment
Powered by Google Project Hosting