File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ Autorize this policy :
2727 "Effect": "Allow",
2828 "Action": [
2929 "cloudwatch:PutMetricAlarm",
30- "cloudwatch:PutMetricData"
30+ "cloudwatch:PutMetricData",
31+ "cloudwatch:DeleteAlarms"
3132 ],
3233 "Resource": [
3334 "*"
@@ -63,6 +64,11 @@ Create alarme in Cloud Watch (Run one time)
6364php alarmes.php [-f config-file]
6465```
6566
67+ Delte alarme in Cloud Watch (Run one time)
68+ ```
69+ php delete-alarmes.php [-f config-file]
70+ ```
71+
6672## Plugins
6773
6874| Name | Description |
Original file line number Diff line number Diff line change 1+ <?php
2+ define ('APPLICATION_PATH ' , realpath (dirname (__FILE__ )));
3+
4+ include APPLICATION_PATH . '/vendor/autoload.php ' ;
5+ require_once 'lib.php ' ;
6+
7+ use Aws \CloudWatch \CloudWatchClient ;
8+
9+ // Load config file.
10+ $ conf = getConfigFile ();
11+ if ($ conf === false ) {
12+ echo "Conf file is not valid " ;
13+ die ();
14+ }
15+ // Store metric by namespace in order to call "AWS Could Watch" one time per namespace
16+ $ metricsToPush = array ();
17+
18+ // Get Instance Id
19+ $ instanceId = file_get_contents ("http://169.254.169.254/latest/meta-data/instance-id " );
20+
21+ $ client = getCloudWatchClient ($ conf );
22+
23+ foreach ($ conf ->metrics as $ metrics ) {
24+ foreach ($ metrics as $ metricName => $ metric ) {
25+ $ pluginName = isset ($ metric ->{'plugin ' })===true ?$ metric ->{'plugin ' }:$ metricName ;
26+ $ className = "CloudWatchScript \\Plugins \\" . $ pluginName . "Monitoring " ;
27+
28+ $ metricController = new $ className ($ metric , $ metric ->name );
29+
30+ foreach ($ metricController ->getAlarms () as $ key => $ alarm ) {
31+ $ client ->deleteAlarms (array (
32+ 'AlarmNames ' => array ($ alarm ["Name " ])
33+ ));
34+ }
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments