-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdelete-alarmes.php
34 lines (26 loc) · 911 Bytes
/
delete-alarmes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__)));
include APPLICATION_PATH . '/vendor/autoload.php';
require_once 'lib.php';
use Aws\CloudWatch\CloudWatchClient;
// Load config file.
$conf = getConfigFile();
if ($conf === false) {
echo "Conf file is not valid";
die();
}
$client = getCloudWatchClient($conf);
$alarmsToDelete = [];
foreach ($conf->metrics as $metrics) {
foreach ($metrics as $metricName => $metric) {
$pluginName = isset($metric->{'plugin'}) === true ? $metric->{'plugin'} : $metricName;
$className = "CloudWatchScript\\Plugins\\" . $pluginName . "Monitoring";
$metricController = new $className($metric, $metric->name);
foreach ($metricController->getAlarms() as $key => $alarm) {
$alarmsToDelete[] = $alarm["Name"];
}
}
}
$client->deleteAlarms(array(
'AlarmNames' => $alarmsToDelete
));