Commit ecee8846 by Fred Smith

update nr display name to instanceid on aws

parent ef8f4998
#! /usr/bin/env bash
if command -v ec2metadata >/dev/null 2>&1; then
INSTANCEID=$(ec2metadata --instance-id);
HOSTNAME=$(hostname)
DISPLAY_NAME="$HOSTNAME-$INSTANCEID"
if [[ -f /etc/newrelic/nrsysmond.cfg ]]; then
sudo sed -i 's/^hostname=.*//g' /etc/newrelic/nrsysmond.cfg
echo "hostname=\"$DISPLAY_NAME\"" | sudo tee -a /etc/newrelic/nrsysmond.cfg
sudo service newrelic-sysmond restart
fi
if [[ -f /etc/newrelic-infra.yml ]]; then
sudo sed -i 's/^display_name: .*//g' /etc/newrelic-infra.yml
echo "display_name: \"$DISPLAY_NAME\"" | sudo tee -a /etc/newrelic-infra.yml
sudo service newrelic-infra restart
fi
fi
...@@ -81,6 +81,21 @@ ...@@ -81,6 +81,21 @@
- install:app-requirements - install:app-requirements
when: ansible_distribution == 'Amazon' when: ansible_distribution == 'Amazon'
- name: Install newrelic display name script
copy:
src: "edx/bin/write_nr_display_name_config.sh"
dest: "/edx/bin/write_nr_display_name_config.sh"
owner: root
group: root
mode: u=rwx,g=r,o=r
- name: Run newrelic display name script on boot
lineinfile:
path: "/etc/rc.local"
line: "/edx/bin/write_nr_display_name_config.sh"
insertbefore: "exit 0"
mode: "u+x,g+x"
- name: Restart the infrastructure agent if the license key changes - name: Restart the infrastructure agent if the license key changes
service: service:
name: newrelic-infra name: newrelic-infra
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment