/
check_cloudwatch.sh
executable file
·52 lines (38 loc) · 1.32 KB
/
check_cloudwatch.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Include path so we can execute commands like 'python'
PATH=$PATH:/usr/bin
export PATH
# script location
AfPath=/usr/share/appfirst/plugins/libexec/AfPoller
# IFS is field separator
IFS=","
# Count the total run
let "metricTotal=0"
## Application Name
## Name metrics are sorted with in statsd buckets
appname=AWSdemo
## any additional program execution flags, IE --test or --dry-run (or both)
flags="--test --dry-run"
## AWS IAM Role Credentials, Recommended CloudWatch Read Only
access_key=""
access_secret=""
## Single Namespace (recommend one script per namespace)
## ie, aws_billing for AWS/Billing, aws_ec2_metrics for AWS/EC2, etc
namespace="AWS/EBS"
## IFS separator list, if you have multiple items to collect
instances=""
## IFS separator list of regions
region="us-west"
# IFS separated list of all the metrics you wish to collect
metriclist=""
for instance in $instances
do
for metric in $metriclist
do
# increment the counter
let "metricTotal++"
python $AfPath/AfPoller.py --plugin=cloudwatch --amazon-access-key-id=$access_key --amazon-access-secret-key=$access_secret --metricname=$metric --namespace=$namespace --dimension=VolumeId:$instance --application=$appname --region=$region
done
done
## Output basic nagios-format "OK" so the polled data script knows this executed
echo "$0 OK $metricTotal"