Skip to content

Instantly share code, notes, and snippets.

@serkanh
Last active August 7, 2019 03:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save serkanh/c75a323218cc220f8ea188066838faaa to your computer and use it in GitHub Desktop.
Save serkanh/c75a323218cc220f8ea188066838faaa to your computer and use it in GitHub Desktop.
aws user-data script to monitor memory & volume utilization of ec2 instances
#/bin/bash
sudo yum install unzip wget perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA -y
wget -O ~ec2-user/CloudWatchMonitoringScripts-1.2.1.zip http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip
cd ~ec2-user && unzip CloudWatchMonitoringScripts-1.2.1.zip
chown ec2-user:ec2-user ~ec2-user/aws-scripts-mon
rm CloudWatchMonitoringScripts-1.2.1.zip
crontab -l > ~ec2-user/mycron
echo "*/5 * * * * ~ec2-user/aws-scripts-mon/mon-put-instance-data.pl --disk-space-util --disk-path=/ --from-cron" >> ~ec2-user/mycron
echo "*/5 * * * * ~ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-used --mem-avail --swap-used" >> ~ec2-user/mycron
crontab ~ec2-user/mycron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment