Created
May 19, 2020 14:56
-
-
Save amit-gshe/846444924e63cae3b31c80829b60104b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
CLOUD_WATCH_AGENT_URL=https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm | |
CLOUD_WATCH_AGENT_CONFIG_URL=https://gist.githubusercontent.com/amit-gshe/5849485bb1bdec8192e9c7b190994151/raw/6bc8175460add58e8ba8c354b617abebc053730d/config.json | |
check_command() { | |
for command in $@ | |
do | |
if ! [ -x "$(command -v $command)" ]; then | |
echo "Error: command $command not exists" | |
exit 1 | |
fi | |
done | |
} | |
download() { | |
echo "Downloading the $1..." | |
curl -C - --connect-timeout 10 --speed-limit 1024 -# -J -O $2 | |
if [ $? -ne 0 ]; then | |
echo "Failed to download the $1" | |
exit 1 | |
fi | |
} | |
check_command curl | |
download "cloud watch agent" $CLOUD_WATCH_AGENT_URL | |
download "cloud watch agent config" $CLOUD_WATCH_AGENT_CONFIG_URL | |
sudo rpm -U ./amazon-cloudwatch-agent.rpm | |
sudo cp ./config.json /opt/aws/amazon-cloudwatch-agent/bin/ | |
sudo mkdir -p /usr/share/collectd | |
sudo touch /usr/share/collectd/types.db | |
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s | |
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment