Monitoring Memory and Disk Metrics for Amazon EC2 Linux Instances

From DevOps Notebook
Revision as of 13:44, 8 November 2019 by MilosZ (talk | contribs)

Requirements

In order for script to work either IAM role or awscreds.conf file needs to be configure.

Required packages

Amazon Linux

  • login with ec2-user
$ sudo yum install -y perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA.x86_64

Ubuntu

  • login with ubuntu user
$ sudo apt-get update && \
  sudo apt-get install libwww-perl libdatetime-perl unzip

Install Monitoring Scripts

$ cd /opt/ && 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 && \
  cd aws-scripts-mon

Setup crontab

Crontab needs to be setup in order to push data periodically to cloudwatch Bellow cron is example, you should add paremeters for metrics you need.

*/5 * * * * /opt/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-util --disk-space-util --disk-path=/ --from-cron