Last active
April 30, 2020 15:51
-
-
Save njbair/1281a1aad2f24886914c1bb36a518166 to your computer and use it in GitHub Desktop.
Unused Forge recipes
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
# run this recipe as the user, not root. | |
if [ ! $( grep "\.config\/composer\/vendor\/bin" ~/.bashrc) ]; then | |
echo 'export PATH="$PATH:$HOME/.config/composer/vendor/bin"' >> ~/.bashrc | |
fi |
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
# This script enables per-second metrics in AWS CloudWatch. | |
# THIS IS VERY EXPENSIVE!!! | |
if [ ! $(command -v amazon-cloudwatch-agent-ctl) ]; then | |
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb | |
dpkg -i -E ./amazon-cloudwatch-agent.deb | |
rm amazon-cloudwatch-agent.deb | |
fi | |
cat << EOF > /opt/aws/amazon-cloudwatch-agent/bin/config.json | |
{ | |
"agent": { | |
"metrics_collection_interval": 1, | |
"run_as_user": "cwagent" | |
}, | |
"metrics": { | |
"metrics_collected": { | |
"cpu": { | |
"measurement": [ | |
"cpu_usage_active", | |
"cpu_usage_idle", | |
"cpu_usage_iowait", | |
"cpu_usage_user", | |
"cpu_usage_system" | |
], | |
"metrics_collection_interval": 1, | |
"totalcpu": true | |
}, | |
"disk": { | |
"measurement": [ | |
"used_percent", | |
"inodes_free" | |
], | |
"metrics_collection_interval": 1, | |
"resources": [ | |
"*" | |
] | |
}, | |
"diskio": { | |
"measurement": [ | |
"io_time", | |
"write_bytes", | |
"read_bytes", | |
"writes", | |
"reads" | |
], | |
"metrics_collection_interval": 1, | |
"resources": [ | |
"*" | |
] | |
}, | |
"mem": { | |
"measurement": [ | |
"mem_used_percent" | |
], | |
"metrics_collection_interval": 1 | |
}, | |
"netstat": { | |
"measurement": [ | |
"tcp_established", | |
"tcp_time_wait" | |
], | |
"metrics_collection_interval": 1 | |
}, | |
"swap": { | |
"measurement": [ | |
"swap_used_percent" | |
], | |
"metrics_collection_interval": 1 | |
} | |
} | |
} | |
} | |
EOF | |
/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 |
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
EFS_VOLUME="fs-xxxxxxxx:/" | |
EFS_MOUNT_POINT="/efs/forge-1" | |
# install NFS utilities | |
apt-get update | |
apt-get install -y nfs-common binutils | |
# download and install EFS Helper | |
git clone https://github.com/aws/efs-utils /root/efs-utils | |
cd efs-utils | |
bash ./build-deb.sh | |
sudo apt-get -y install ./build/amazon-efs-utils*deb | |
cd | |
rm -rf /root/efs-utils | |
mkdir -p $EFS_MOUNT_POINT | |
# create the /etc/fstab entry | |
if ! grep -q 'forge-efs' /etc/fstab ; then | |
echo "$EFS_VOLUME $EFS_MOUNT_POINT efs defaults 0 2" >> /etc/fstab | |
fi | |
# mount the volume | |
mount $EFS_MOUNT_POINT |
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
# Enable sudo without password for Forge user | |
echo "forge ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/99-forge |
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
# This script disables the current CloudWatch Agent configuration. | |
# THIS IS WAY CHEAPER!!! | |
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a stop | |
apt-get --purge remove -y amazon-cloudwatch-agent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment