-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathuser-data.sh
57 lines (48 loc) · 1.91 KB
/
user-data.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
53
54
55
56
57
#!/bin/bash
set -e
yum install -y aws-cli awslogs jq wget
# copy configurations
aws s3 cp s3://${bucket_id}/ecs.config /etc/ecs/ecs.config
aws s3 cp s3://${bucket_id}/awslogs.conf /etc/awslogs/awslogs.conf
# substitute container id
instanceId=$(curl 169.254.169.254/latest/meta-data/instance-id)
sed -i -e "s/{container_instance_id}/$instanceId/g" /etc/awslogs/awslogs.conf
# substitute region
region=$(curl 169.254.169.254/latest/meta-data/placement/availability-zone | sed s'/.$//')
sed -i -e "s/region = us-east-1/region = $region/g" /etc/awslogs/awscli.conf
# start aws logs
service awslogs start
chkconfig awslogs on
# configure and start new relic server monitoring
if [ "${newrelic_license_key}" = "none" ]; then
echo "no newrelic key set, skipping"
else
echo "configuring newrelic"
rpm -Uvh https://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
yum install -y newrelic-sysmond
nrsysmond-config --set license_key=${newrelic_license_key}
echo "labels=Type:cluster;VPC:${vpc};Instance:$instanceId" >> /etc/newrelic/nrsysmond.cfg
/etc/init.d/newrelic-sysmond start
fi
# configure and start ruxit monitoring
if [ "${ruxit_account}" = "none" ]; then
echo "no ruxit account set, skipping"
else
echo "configuring ruxit"
pushd /usr/local/src
wget -O ruxit-agent-install.sh https://${ruxit_account}.live.ruxit.com/installer/agent/unix/latest/${ruxit_token}
chmod u+x ./ruxit-agent-install.sh
./ruxit-agent-install.sh
popd
fi
# configure and start sysdig monitoring (docker version not available in ECS)
if [ "${sysdig_access_key}" = "none" ]; then
echo "no sysdig key set, skipping"
else
echo "configuring sysdig"
pushd /usr/local/src
wget -O sysdig-agent-install.sh https://s3.amazonaws.com/download.draios.com/stable/install-agent
chmod u+x ./sysdig-agent-install.sh
./sysdig-agent-install.sh --access_key ${sysdig_access_key} --tags "instanceid:$instanceId"
popd
fi