Service/Amazon/Ec2/CloudWatch.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Service_Amazon
- Subpackage
- Ec2
- Version
- $Id: CloudWatch.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Service_Amazon_Ec2_CloudWatch
An Amazon EC2 interface that allows yout to run, terminate, reboot and describe Amazon Ec2 Instances.
- Parent(s)
- \Zend_Service_Amazon_Ec2_Abstract < \Zend_Service_Amazon_Abstract < \Zend_Service_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties


string $_accessKey =
- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_accessKey
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_accessKey


string $_defaultAccessKey = null
null
Details- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultAccessKey
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_defaultAccessKey


string $_defaultRegion = null
null
Details- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_defaultRegion


string $_defaultSecretKey = null
null
Details- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_defaultSecretKey
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_defaultSecretKey


$_ec2Endpoint = 'monitoring.amazonaws.com'
The HTTP query server
'monitoring.amazonaws.com'
Details- Type
- n/a


$_ec2SignatureMethod = 'HmacSHA256'
Signature Encoding Method
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::$$_ec2SignatureMethod'HmacSHA256'
Details- Type
- n/a
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_ec2SignatureMethod


$_ec2SignatureVersion = '2'
Signature Version
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::$$_ec2SignatureVersion'2'
Details- Type
- n/a
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_ec2SignatureVersion


\Zend_Http_Client $_httpClient = null
HTTP Client used to query all web services
Inherited from: \Zend_Service_Abstract::$$_httpClient\Zend_Service_Amazon_Abstract::$$_httpClient\Zend_Service_Amazon_Ec2_Abstract::$$_httpClientnull
Details- Type
- \Zend_Http_Client
- Inherited_from
- \Zend_Service_Abstract::$$_httpClient
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_httpClient
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_httpClient


$_httpTimeout = 10
Period after which HTTP request will timeout in seconds
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::$$_httpTimeout10
Details- Type
- n/a
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_httpTimeout


string $_region =
- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_region


string $_secretKey =
- Type
- string
- Inherited_from
- \Zend_Service_Amazon_Abstract::$$_secretKey
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_secretKey


array $_validDimensionsKeys = array('ImageId', 'AvailabilityZone', 'AutoScalingGroupName', 'InstanceId', 'InstanceType', 'LoadBalancerName')
Valid Dimention Keys for getMetricStatistics
ImageId: This dimension filters the data you request for all instances running this EC2 Amazon Machine Image (AMI).
AvailabilityZone: This dimension filters the data you request for all instances running in that EC2 Availability Zone.
AutoScalingGroupName: This dimension filters the data you request for all instances in a specified capacity group. An AutoScalingGroup is a collection of instances defined by customers of the Auto Scaling service. This dimension is only available for EC2 metrics when the instances are in such an AutoScalingGroup.
InstanceId: This dimension filters the data you request for only the identified instance. This allows a user to pinpoint an exact instance from which to monitor data.
InstanceType: This dimension filters the data you request for all instances running with this specified instance type. This allows a user to catagorize his data by the type of instance running. For example, a user might compare data from an m1.small instance and an m1.large instance to determine which has the better business value for his application.
LoadBalancerName: This dimension filters the data you request for the specified LoadBalancer name. A LoadBalancer is represented by a DNS name and provides the single destination to which all requests intended for your application should be directed. This metric allows you to examine data from all instances connected to a single LoadBalancer.
array('ImageId', 'AvailabilityZone', 'AutoScalingGroupName', 'InstanceId', 'InstanceType', 'LoadBalancerName')
Details- Type
- array


array $_validEc2Regions = array('eu-west-1', 'us-east-1')
An array that contains all the valid Amazon Ec2 Regions.
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::$$_validEc2Regionsarray('eu-west-1', 'us-east-1')
Details- Type
- array
- Inherited_from
- \Zend_Service_Amazon_Ec2_Abstract::$$_validEc2Regions


array $_validMetrics = array('CPUUtilization', 'NetworkIn', 'NetworkOut', 'DiskWriteOps', 'DiskReadBytes', 'DiskReadOps', 'DiskWriteBytes', 'Latency', 'RequestCount', 'HealthyHostCount', 'UnHealthyHostCount')
The following metrics are available from each EC2 instance.
CPUUtilization: The percentage of allocated EC2 compute units that are currently in use on the instance. This metric identifies the processing power required to run an application upon a selected instance.
NetworkIn: The number of bytes received on all network interfaces by the instance. This metric identifies the volume of incoming network traffic to an application on a single instance.
NetworkOut: The number of bytes sent out on all network interfaces by the instance. This metric identifies the volume of outgoing network traffic to an application on a single instance.
DiskWriteOps: Completed write operations to all hard disks available to the instance. This metric identifies the rate at which an application writes to a hard disk. This can be used to determine the speed in which an application saves data to a hard disk.
DiskReadBytes: Bytes read from all disks available to the instance. This metric is used to determine the volume of the data the application reads from the hard disk of the instance. This can be used to determine the speed of the application for the customer.
DiskReadOps: Completed read operations from all disks available to the instances. This metric identifies the rate at which an application reads a disk. This can be used to determine the speed in which an application reads data from a hard disk.
DiskWriteBytes: Bytes written to all disks available to the instance. This metric is used to determine the volume of the data the application writes onto the hard disk of the instance. This can be used to determine the speed of the application for the customer.
Latency: Time taken between a request and the corresponding response as seen by the load balancer.
RequestCount: The number of requests processed by the LoadBalancer.
HealthyHostCount: The number of healthy instances. Both Load Balancing dimensions, LoadBalancerName and AvailabilityZone, should be specified when retreiving HealthyHostCount.
UnHealthyHostCount: The number of unhealthy instances. Both Load Balancing dimensions, LoadBalancerName and AvailabilityZone, should be specified when retreiving UnHealthyHostCount.
Amazon CloudWatch data for a new EC2 instance becomes available typically within one minute of the end of the first aggregation period for the new instance. You can use the currently available dimensions for EC2 instances along with these metrics in order to refine the slice of data you want returned, such as metric CPUUtilization and dimension ImageId to get all CPUUtilization data for instances using the specified AMI.
array('CPUUtilization', 'NetworkIn', 'NetworkOut', 'DiskWriteOps', 'DiskReadBytes', 'DiskReadOps', 'DiskWriteBytes', 'Latency', 'RequestCount', 'HealthyHostCount', 'UnHealthyHostCount')
Details- Type
- array


array $_validStatistics = array('Average', 'Maximum', 'Minimum', 'Samples', 'Sum')
Amazon CloudWatch not only aggregates the raw data coming in, it also computes several statistics on the data.
The following table lists the statistics that you can request:
Minimum: The lowest value observed during the specified period. This can be used to determine low volumes of activity for your application.
Maximum: The highest value observed during the specified period. You can use this to determine high volumes of activity for your application.
Sum: The sum of all values received (if appropriate, for example a rate would not be summed, but a number of items would be). This statistic is useful for determining the total volume of a metric.
Average: The Average of all values received during the specified period. By comparing this statistic with the minimum and maximum statistics, you can determine the full scope of a metric and how close the average use is to the minimum and the maximum. This will allow you to increase or decrease your resources as needed.
Samples: The count (number) of measures used. This statistic is always returned to show the user the size of the dataset collected. This will allow the user to properly weight the data.
Statistics are computed within a period you specify, such as all CPUUtilization within a five minute period. At a minimum, all data is aggregated into one minute intervals. This is the minimum resolution of the data. It is this data that can be aggregated into larger periods of time that you request.
Aggregate data is generally available from the service within one minute from the end of the aggregation period. Delays in data propagation might cause late or partially late data in some cases. If your data is delayed, you should check the service’s Health Dashboard for any current operational issues with either Amazon CloudWatch or the services collecting the data, such as EC2 or Elastic Load Balancing.
array('Average', 'Maximum', 'Minimum', 'Samples', 'Sum')
Details- Type
- array
Methods


__construct( $accessKey = null, $secretKey = null, string $region = null) : void
Name | Type | Description |
---|---|---|
$accessKey | ||
$secretKey | ||
$region | string | Sets the AWS Region |


_getAccessKey() : string
Method to fetch the Access Key
Inherited from: \Zend_Service_Amazon_Abstract::_getAccessKey()\Zend_Service_Amazon_Ec2_Abstract::_getAccessKey()Type | Description |
---|---|
string |


_getRegion() : string
Method to fetch the AWS Region
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::_getRegion()Type | Description |
---|---|
string |


_getSecretKey() : string
Method to fetch the Secret AWS Key
Inherited from: \Zend_Service_Amazon_Abstract::_getSecretKey()\Zend_Service_Amazon_Ec2_Abstract::_getSecretKey()Type | Description |
---|---|
string |


addRequiredParameters(array $parameters) : array
Adds required authentication and version parameters to an array of parameters
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::addRequiredParameters()The required parameters are: - AWSAccessKey - SignatureVersion - Timestamp - Version and - Signature
If a required parameter is already set in the $parameters array, it is overwritten.
Name | Type | Description |
---|---|---|
$parameters | array | the array to which to add the required parameters. |
Type | Description |
---|---|
array |


checkForErrors(\Zend_Service_Amazon_Ec2_Response $response) : void
Checks for errors responses from Amazon
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::checkForErrors()Name | Type | Description |
---|---|---|
$response | \Zend_Service_Amazon_Ec2_Response | the response object to check. |
Exception | Description |
---|---|
\Zend_Service_Amazon_Ec2_Exception | if one or more errors are returned from Amazon. |


getHttpClient() : \Zend_Http_Client
Gets the HTTP client object.
Inherited from: \Zend_Service_Abstract::getHttpClient()\Zend_Service_Amazon_Abstract::getHttpClient()\Zend_Service_Amazon_Ec2_Abstract::getHttpClient()Type | Description |
---|---|
\Zend_Http_Client |


getMetricStatistics(array $options) : void
Returns data for one or more statistics of given a metric
Note: The maximum number of datapoints that the Amazon CloudWatch service will return in a single GetMetricStatistics request is 1,440. If a request is made that would generate more datapoints than this amount, Amazon CloudWatch will return an error. You can alter your request by narrowing the time range (StartTime, EndTime) or increasing the Period in your single request. You may also get all of the data at the granularity you originally asked for by making multiple requests with adjacent time ranges.
Name | Type | Description |
---|---|---|
$options | array | The options you want to get statistics for: ** Required ** MeasureName: The measure name that corresponds to the measure for the gathered metric. Valid EC2 Values are CPUUtilization, NetworkIn, NetworkOut, DiskWriteOps DiskReadBytes, DiskReadOps, DiskWriteBytes. Valid Elastic Load Balancing Metrics are Latency, RequestCount, HealthyHostCount UnHealthyHostCount Statistics: The statistics to be returned for the given metric. Valid values are Average, Maximum, Minimum, Samples, Sum. You can specify this as a string or as an array of values. If you don't specify one it will default to Average instead of failing out. If you specify an incorrect option it will just skip it. ** Optional ** Dimensions: Amazon CloudWatch allows you to specify one Dimension to further filter metric data on. If you don't specify a dimension, the service returns the aggregate of all the measures with the given measure name and time range. Unit: The standard unit of Measurement for a given Measure. Valid Values: Seconds, Percent, Bytes, Bits, Count, Bytes/Second, Bits/Second, Count/Second, and None Constraints: When using count/second as the unit, you should use Sum as the statistic instead of Average. Otherwise, the sample returns as equal to the number of requests instead of the number of 60-second intervals. This will cause the Average to always equals one when the unit is count/second. StartTime: The timestamp of the first datapoint to return, inclusive. For example, 2008-02-26T19:00:00+00:00. We round your value down to the nearest minute. You can set your start time for more than two weeks in the past. However, you will only get data for the past two weeks. (in ISO 8601 format) Constraints: Must be before EndTime EndTime: The timestamp to use for determining the last datapoint to return. This is the last datapoint to fetch, exclusive. For example, 2008-02-26T20:00:00+00:00. (in ISO 8601 format) |


listMetrics(string $nextToken = null) : array
Return the Metrics that are aviable for your current monitored instances
Name | Type | Description |
---|---|---|
$nextToken | string | The NextToken parameter is an optional parameter that allows you to retrieve the next set of results for your ListMetrics query. |
Type | Description |
---|---|
array |


sendRequest(array $params = array()) : \Zend_Service_Amazon_Ec2_Response
Sends a HTTP request to the queue service using Zend_Http_Client
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::sendRequest()Name | Type | Description |
---|---|---|
$params | array | List of parameters to send with the request |
Type | Description |
---|---|
\Zend_Service_Amazon_Ec2_Response |
Exception | Description |
---|---|
\Zend_Service_Amazon_Ec2_Exception |


setHttpClient(\Zend_Http_Client $httpClient) : void
Sets the HTTP client object to use for retrieving the feeds.
Inherited from: \Zend_Service_Abstract::setHttpClient()\Zend_Service_Amazon_Abstract::setHttpClient()\Zend_Service_Amazon_Ec2_Abstract::setHttpClient()If none is set, the default Zend_Http_Client will be used.
Name | Type | Description |
---|---|---|
$httpClient | \Zend_Http_Client |


setKeys( $accessKey, $secretKey) : void
Set the keys to use when accessing SQS.
Inherited from: \Zend_Service_Amazon_Abstract::setKeys()\Zend_Service_Amazon_Ec2_Abstract::setKeys()Name | Type | Description |
---|---|---|
$accessKey | ||
$secretKey |


setRegion(string $region) : void
Set which region you are working in.
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::setRegion()It will append the end point automaticly
Name | Type | Description |
---|---|---|
$region | string |


signParameters( $paramaters) : string
Computes the RFC 2104-compliant HMAC signature for request parameters
Inherited from: \Zend_Service_Amazon_Ec2_Abstract::signParameters()This implements the Amazon Web Services signature, as per the following specification:
Sort all request parameters (including SignatureVersion and excluding Signature, the value of which is being created), ignoring case.
Iterate over the sorted list and append the parameter name (in its original case) and then its value. Do not URL-encode the parameter values before constructing this string. Do not use any separator characters when appending strings.
Name | Type | Description |
---|---|---|
$paramaters |
Type | Description |
---|---|
string | the signed data. |