* http://aws.amazon.com/apache2.0/ * * or in the "license.txt" file accompanying this file. This file is * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS * OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the * License. * * Modified by Jeffrey S. Haemer <*****@*****.**> */ error_reporting(E_ALL); require_once 'AWSSDKforPHP/sdk.class.php'; // Create the CloudWatch access object $cw = new AmazonCloudWatch(); // Get the metrics $res = $cw->list_metrics(); if ($res->isOK()) { $metrics = $res->body->ListMetricsResult->Metrics->member; $metricsRows = array(); // Build array of available metrics foreach ($metrics as $metric) { $metricsRows[] = array('MetricName' => (string) $metric->MetricName, 'Namespace' => (string) $metric->Namespace, 'Name' => (string) $metric->Dimensions->member->Name, 'Value' => (string) $metric->Dimensions->member->Value); } // Sort the metrics usort($metricsRows, 'CmpMetrics'); // Display a header and then the metrics printf("%-16s %-20s %-16s %-16s\n", "Namespace", "Metric Name", "Name", "Value"); printf("%-16s %-20s %-16s %-16s\n", "=========", "============", "====", "====="); foreach ($metricsRows as $metricsRow) { printf("%-16s %-20s %-16s %-16s\n", $metricsRow['Namespace'], $metricsRow['MetricName'], $metricsRow['Name'], $metricsRow['Value']); }