Skip to content

Instantly share code, notes, and snippets.

@yicr
Created February 22, 2019 06:51
Show Gist options
  • Save yicr/f845feba2ca6de69049c8f138e97c450 to your computer and use it in GitHub Desktop.
Save yicr/f845feba2ca6de69049c8f138e97c450 to your computer and use it in GitHub Desktop.
EC2 Memory Usage & Disk Usage Watching by CloudWatch

1. Install package

$ sudo yum -y install perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https

2. Install Amazon CloudWatch Monitoring Scripts

$ curl https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip -O
$ unzip CloudWatchMonitoringScripts-1.2.2.zip && \
rm CloudWatchMonitoringScripts-1.2.2.zip && \
$ sudo mv aws-scripts-mon /usr/local/

Use IAM policy

$ sudo vim /etc/crontab
# aws-scripts-mon
*/5 * * * * root /usr/local/aws-scripts-mon/mon-put-instance-data.pl --mem-util --mem-used --mem-avail --from-cron
*/5 * * * * root /usr/local/aws-scripts-mon/mon-put-instance-data.pl --disk-space-util --disk-path=/ --from-cron

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment