Skip to content

Instantly share code, notes, and snippets.

@pwillis-els
Created September 23, 2019 11:08
Show Gist options
  • Save pwillis-els/da890b91e4cabd1ffdbae2b5ad5ee534 to your computer and use it in GitHub Desktop.
Save pwillis-els/da890b91e4cabd1ffdbae2b5ad5ee534 to your computer and use it in GitHub Desktop.
Install NewRelic agent on EC2
#!/bin/bash
if [ ! -n "$LICENSE_KEY" ] ; then
read -p "NewRelic license key: " LICENSE_KEY
fi
if [ -z "$LICENSE_KEY" ] ; then
echo "Error: failed to read license key" ; exit 1
fi
echo "license_key: $LICENSE_KEY" | sudo tee -a /etc/newrelic-infra.yml
if grep "Amazon Linux 2" /etc/os-release ; then
sudo curl -s -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/7/x86_64/newrelic-infra.repo
elif grep "Amazon Linux" /etc/os-release ; then
sudo curl -o /etc/yum.repos.d/newrelic-infra.repo https://download.newrelic.com/infrastructure_agent/linux/yum/el/6/x86_64/newrelic-infra.repo
else
echo "Error: could not detect OS, failing" ; exit 1
fi
sudo yum -q makecache -y --disablerepo='*' --enablerepo='newrelic-infra'
sudo yum install newrelic-infra -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment