AWS provides its user the Cloud Monitoring service which is used to keep a check on the resources being used.
It can be a great tool for developers and system administrators for cases like:
- Monitoring data/graphs
- Setting up alarms
- Identify trends
- Take actions based on the state of cloud environment
But AWS does not provide the memory and the disk utilization metrics out of the box.These metrics can be monitored using third party scripts that are are written in Perl and are verified by AWS.
To install the scripts a few very basic and simple steps need to be followed, which are:
We’ll have to install the following packages to get these scripts to work.
For Debian Flavored Servers,
[shell]sudo apt-get install unzip libwww-perl libcrypt-ssleay-perl[/shell]
For Red Hat Flavored Servers,
yum install perl-Digest-SHA1
perl -MCPAN -e shell ## Type ‘yes’ at every prompt, this will drop you at cpan prompt.
cpan> install Bundle::LWP5_837 LWP ## Here also type ‘yes’ at every prompt.[/shell]
Now we will download and configure the CloudWatch Monitoring Scripts on EC2 Linux system.
Following are the steps which we need to follow:
open the awscreds.template file and enter your accesskeyid and secret key[/shell]
Above mentioned commands will set up the the required monitoring for us. Next step for us would be to send memory and disk usage details to CloudWatch, which would enable us to access information and setup alarms from AWS CloudWatch console.
The command below runs every minute and pushes data to CloudWatch. And to enable 1 minute granularity in CloudWatch we would also need to enable “Detailed Monitoring”.
[shell]*/1 * * * * /opt/aws-scripts-mon/mon-put-instance-data.pl –mem-util –disk-space-util –swap-util –disk-path=/ –disk-path=/data –aws-credential-file=/opt/mon-scripts/awscreds.template[/shell]
In the above command we are monitoring two EBS volumes, one is Root volume and another volume which we have mounted on /data directory. It will push data every minute to CloudWatch.
Now you can set the alarm on your memory and disk utilization as per your application’s requirement.