Skip to content

Commit 031f233

Browse files
authored
Merge pull request #10 from PatriceT/master
Add settings for period and action per metric
2 parents a1d4d42 + 2a27665 commit 031f233

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

alarmes.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323
$instanceId = file_get_contents("http://169.254.169.254/latest/meta-data/instance-id");
2424
}
2525

26+
2627
$client = getCloudWatchClient($conf);
2728

2829
foreach ($conf->metrics as $metrics) {
2930
foreach ($metrics as $metricName => $metric) {
3031
$pluginName = isset($metric->{'plugin'})===true?$metric->{'plugin'}:$metricName;
3132
$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;
3235

3336
$metricController = new $className($metric, $metric->name);
3437

@@ -37,17 +40,17 @@
3740
'AlarmName' => $alarm["Name"],
3841
'AlarmDescription' => $metric->description,
3942
'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),
4346
'Dimensions' => array(
4447
array('Name' => 'InstanceId', 'Value' => $instanceId),
4548
array('Name' => 'Metrics', 'Value' => $metricName)
4649
),
4750
'MetricName' => $metricController->getMetricName($alarm["Name"]),
4851
'Namespace' => $metric->namespace,
4952
'Statistic' => 'Average',
50-
'Period' => 300,
53+
'Period' => $period,
5154
'Unit' => $metricController->getUnit($alarm["Name"]),
5255
// EvaluationPeriods is required
5356
'EvaluationPeriods' => 2,

conf/config_sample.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"aws": {
33
"key":"YOUR_KEY",
44
"secret":"YOUR_SECRET",
5-
"region":"YUR_REGION",
5+
"region":"YOUR_REGION",
66
"instance":"INSTANCE_ID"
77
},
88
"alarms" : {
@@ -14,7 +14,9 @@
1414
"name" : "Solr",
1515
"url": "http://localhost:8080/solr/collection1/admin/ping",
1616
"namespace": "YOUR_NAMESPACE",
17-
"description": "YOUR_COMMENT"
17+
"description": "YOUR_COMMENT",
18+
"period": "YOUR_PERIOD (optional, must be 10, 30 or a multiple of 60)",
19+
"action": "YOUR_SPECIFIC_ACTION_ARM (optional)"
1820
}
1921
}
2022
]

0 commit comments

Comments
 (0)