|
23 | 23 | $instanceId = file_get_contents("http://169.254.169.254/latest/meta-data/instance-id"); |
24 | 24 | } |
25 | 25 |
|
| 26 | + |
26 | 27 | $client = getCloudWatchClient($conf); |
27 | 28 |
|
28 | 29 | foreach ($conf->metrics as $metrics) { |
29 | 30 | foreach ($metrics as $metricName => $metric) { |
30 | 31 | $pluginName = isset($metric->{'plugin'})===true?$metric->{'plugin'}:$metricName; |
31 | 32 | $className = "CloudWatchScript\\Plugins\\" . $pluginName . "Monitoring"; |
| 33 | + $period = isset($metric->period) === true ? $metric->period : 300; |
| 34 | + $action = isset($metric->action) === true ? $metric->action : $conf->alarms->action; |
32 | 35 |
|
33 | 36 | $metricController = new $className($metric, $metric->name); |
34 | 37 |
|
|
37 | 40 | 'AlarmName' => $alarm["Name"], |
38 | 41 | 'AlarmDescription' => $metric->description, |
39 | 42 | 'ActionsEnabled' => true, |
40 | | - 'OKActions' => array($conf->alarms->action), |
41 | | - 'AlarmActions' => array($conf->alarms->action), |
42 | | - 'InsufficientDataActions' => array($conf->alarms->action), |
| 43 | + 'OKActions' => array($action), |
| 44 | + 'AlarmActions' => array($action), |
| 45 | + 'InsufficientDataActions' => array($action), |
43 | 46 | 'Dimensions' => array( |
44 | 47 | array('Name' => 'InstanceId', 'Value' => $instanceId), |
45 | 48 | array('Name' => 'Metrics', 'Value' => $metricName) |
46 | 49 | ), |
47 | 50 | 'MetricName' => $metricController->getMetricName($alarm["Name"]), |
48 | 51 | 'Namespace' => $metric->namespace, |
49 | 52 | 'Statistic' => 'Average', |
50 | | - 'Period' => 300, |
| 53 | + 'Period' => $period, |
51 | 54 | 'Unit' => $metricController->getUnit($alarm["Name"]), |
52 | 55 | // EvaluationPeriods is required |
53 | 56 | 'EvaluationPeriods' => 2, |
|
0 commit comments