Amazon CloudWatch Monitoring Service (http://aws.amazon.com/cloudwatch)
2009.08.26
2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
| Simplified BSD License | http://opensource.org/licenses/bsd-license.php |
| CloudFusion | http://getcloudfusion.com |
| Amazon CloudWatch | http://aws.amazon.com/cloudwatch |
Specify the default queue URL.
Container for all Amazon CloudWatch-related methods. Inherits additional methods from CloudFusion.
CloudFusion
public function __construct( $key = null, $secret_key = null )
The constructor
public
| key | string (Optional) Your Amazon API Key. If blank, it will look for the AWS_KEY constant. |
| secret_key | string (Optional) Your Amazon API Secret Key. If blank, it will look for the AWS_SECRET_KEY constant. |
boolean false if no valid values are set, otherwise true.
public function list_metrics( $opt = null )
Returns a list of up to 500 valid metrics for which there is recorded data available to a you and a NextToken string that can be used to query for the next set of results.
public
| opt | array (Required) Associative array of parameters which can have the following keys: |
| NextToken | string (Optional) Allows you to retrieve the next set of results for your ListMetrics query. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
ResponseCore object
<?php // Dependencies require_once 'cloudfusion.class.php'; // List metrics $cw = new AmazonCloudWatch(); $response = $cw->list_metrics(); // Success? var_dump($response->isOK()); /** [Expected output] bool(true) */ ?>
<?php
// Dependencies
require_once 'cloudfusion.class.php';
// List metrics
$cw = new AmazonCloudWatch();
$response = $cw->list_metrics(array(
'NextToken' => 't' // Invalid
));
// Success?
var_dump($response->body->Error->Message);
/** [Expected output]
object(SimpleXMLElement)#7 (1) {
[0]=>
string(17) "Invalid nextToken"
}
*/
?>| AWS Method | http://docs.amazonwebservices.com |
public function get_metric_statistics( $measure_name, $statistics, $unit, $start_time, $end_time, $opt = null )
Returns data for one or more statistics of given a metric.
public
| measure_name | string (Required) The measure name that corresponds to the measure for the gathered metric. See http://docs.amazonwebservices.com |
| statistics | string | array (Required) The statistics to be returned for the given metric. You can pass a string for a single statistic, or an indexed array for multiple statistics. See http://docs.amazonwebservices.com |
| unit | string (Required) The standard unit of measurement for a given Measure. See http://docs.amazonwebservices.com |
| start_time | string (Required) A time stamp representing the beginning of the period to get results for. Looks for an ISO-8601 formatted time stamp, but can convert any understandable time stamp into the correct format automatically. |
| end_time | string (Required) A time stamp representing the end of the period to get results for. Looks for an ISO-8601 formatted time stamp, but can convert any understandable time stamp into the correct format automatically. |
| opt | array (Required) Associative array of parameters which can have the following keys: |
| CustomUnit | array (Optional) The user-defined CustomUnit applied to a Measure. |
| Dimensions | array (Optional) 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. See http://docs.amazonwebservices.com |
| Namespace | array (Optional) The namespace corresponding to the service of interest. For example, “AWS/EC2” represents Amazon EC2. |
| Period | integer (Required) The granularity (in seconds) of the returned datapoints. Must be a multiple of 60. Defaults to 60. |
| returnCurlHandle | boolean (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests. |
ResponseCore object
<?php
// Dependencies
require_once 'cloudfusion.class.php';
// Get metrics
$cw = new AmazonCloudWatch();
$response = $cw->get_metric_statistics('CPUUtilization', 'Average', 'Percent', '1 August 2009', '2 August 2009');
// Success?
var_dump($response->isOK());
/** [Expected output]
bool(true)
*/
?> <?php
// Dependencies
require_once 'cloudfusion.class.php';
// Get metrics
$cw = new AmazonCloudWatch();
$response = $cw->get_metric_statistics('CPUUtilization', array('Average', 'Sum'), 'Percent', '1 August 2009', '2 August 2009');
// Success?
var_dump($response->isOK());
/** [Expected output]
bool(true)
*/
?> <?php
// Dependencies
require_once 'cloudfusion.class.php';
// Get metrics
$cw = new AmazonCloudWatch();
$response = $cw->get_metric_statistics('CPUUtilization', 'Average', 'Percent', '1 August 2009', '31 August 2009', array(
'Namespace' => 'AWS/EC2',
'Period' => 1800
));
// Success?
var_dump($response->isOK());
/** [Expected output]
bool(true)
*/
?>| AWS Method | http://docs.amazonwebservices.com |