AWS Memory Stats - Linux

Document created by fadi.josef Expert on Mar 27, 2017Last modified by eva.tuczai on Mar 28, 2018
Version 21Show Document
  • View in full screen mode

In this document, we will look at how we can publish AWS used Memory stats to CloudWatch so that Turbonomic can pull the memory metrics.

 

AWS recently introduced a more programmatic way to add memory stats to CloudWatch through a SSM agent. This approach can be found here: Setting up CloudWatch with your Linux Instances on AWS. The approach below remains viable for the supported Linux operating systems of AWS Linux AMI, RedHat Linux, SUSE, Debian and Ubuntu.

 

If you are running CoreOS as the operating system for your kubernetes / OpenShift nodes, then refer to this article on how to enable the CloudWatch Monitoring Scripts via a container:  Reporting to CloudWatch from CoreOS – Spencer's Blog or http://blogofit.com/monitoring_with_cloudwatch/ 

 

Latest version of the CloudWatch Monitoring Script can be found here: AWS Code 

 

Step 1: Login to your AWS Linux instance 

Step 2: Download the script from AWS Website

curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O

Step 3: Install the required prerequisites 

You must run as root to be able to install these packages.

Amazon Linux AMI

  • sudo yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https

Red Hat Enterprise Linux

  • sudo yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA -y
  • sudo yum install zip unzip

SUSE Linux Enterprise Server

  • sudo zypper install perl-Switch perl-DateTime
  • sudo zypper install –y "perl(LWP::Protocol::https)"

Ubuntu 

  • sudo apt-get update
  • sudo apt-get install unzip curl
  • sudo apt-get install libwww-perl libdatetime-per

Debian

  • apt-get update
  • apt-get install unzip curl
  • apt-get install libwww-perl libdatetime-perl liburi-perl

Step 4: Unzip the downloaded file, and then go to the extracted directory.

unzip CloudWatchMonitoringScripts-1.2.1.zip

cd aws-scripts-mon

Step 5:  Copy the awscreds.template to awscreds.conf 

cp awscreds.template awscreds.conf

Step 6: vi the awscreds.conf file and add your AWS Access Key and AWS Secret Key

AWSAccessKeyId=my-access-key-id

AWSSecretKey=my-secret-access-key

Step 7: Setup a Crontab so that the script runs in the background every 5 minutes.

crontab -e

*/5 * * * * /tmp/aws-scripts-mon/mon-put-instance-data.pl --mem-used

Now you will start seeing the used memory metrics being published to AWS CloudWatch every 5 minutes and then Turbonomic will be able to pull in the stats. 

Attachments

    Outcomes