Created
January 23, 2017 13:32
-
-
Save klcodanr/d5652bc2ed09ddbbfa685ddb671911dc to your computer and use it in GitHub Desktop.
A quick script to install NewRelic on multiple CentOS servers
This file contains 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
#!/bin/bash | |
# Configuration Values | |
LICENSE_KEY= | |
SOLUTION=MySolution | |
SSH_PREFIX=mysolution | |
# END Configuration | |
while IFS='' read -r line || [[ -n "$line" ]]; do | |
params=(${line//;/ }) | |
environment="${params[0]}" | |
type="${params[1]}" | |
name="${params[2]}" | |
ip="${params[3]}" | |
echo "Installing NewRelic on $name..." | |
echo "Adding NewRelic to Yum Repo..." | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n 'sudo rpm -Uvh https://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm' | |
echo "Installing NewRelic..." | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n 'sudo yum install -y newrelic-sysmond' | |
echo "Configuring NewRelic..." | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n "sudo nrsysmond-config --set license_key=$LICENSE_KEY" | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n "sudo echo hostname=$SOLUTION-$name | sudo tee --append /etc/newrelic/nrsysmond.cfg" | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n "sudo echo labels=Environment:$environment\;Application:$type\;Solution:$SOLUTION | sudo tee --append /etc/newrelic/nrsysmond.cfg" | |
echo "Starting NewRelic..." | |
ssh -i ~/.ssh/$SSH_PREFIX-$environment.pem centos@$ip -t -t -n 'sudo /etc/init.d/newrelic-sysmond restart' | |
echo "New Relic Installation Complete!" | |
done < "$1" | |
This file contains 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
prod;Author;prod-Author;127.0.0.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment