Skip to content

Instantly share code, notes, and snippets.

@dduvnjak
Created May 16, 2016 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dduvnjak/1fe1a597264455fd316bc3169a3543ff to your computer and use it in GitHub Desktop.
Save dduvnjak/1fe1a597264455fd316bc3169a3543ff to your computer and use it in GitHub Desktop.
Installs and configures New Relic System Monitoring agent on AWS Elastic Beanstalk instances
# installs and configures New Relic System Monitoring agent
#
files:
"/opt/elasticbeanstalk/get-eb-env-name.py":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env python
import boto.utils
import boto.ec2
iid_doc = boto.utils.get_instance_identity()['document']
region = iid_doc['region']
instance_id = iid_doc['instanceId']
ec2 = boto.ec2.connect_to_region(region)
instance = ec2.get_only_instances(instance_ids=[instance_id])[0]
env = instance.tags['elasticbeanstalk:environment-name']
print(env)
packages:
yum:
newrelic-sysmond: []
rpm:
newrelic: http://yum.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
commands:
1_configure_new_relic_hostname:
command: sed -i "s+#hostname=.*+hostname=`/opt/elasticbeanstalk/get-eb-env-name.py`+g" /etc/newrelic/nrsysmond.cfg
container_commands:
1_configure_new_relic_key:
command: /usr/sbin/nrsysmond-config --set license_key=$NEW_RELIC_LICENSE_KEY
2_start_nrsysmond:
command: /etc/init.d/newrelic-sysmond start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment