0

I followed the steps in this article, http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html#mon-scripts-systems to monitor my server's memory usage and submit the data to CloudWatch.

One of the metrics that can be used is --mem-used-incl-cache-buff which collects and sends the MemoryUsed metrics, reported in megabytes. This option reports used in cache and buffers, as well as memory allocated by applications and the operating system. This memory metric is important compare to other memory metrics because this metric collects memory used in cache and buffers as well. The other memory metrics simply collect free and used memory to determine whether or not my server is running out of memory.

Unfortunately this is the output when I tried to run the script:

[root@ip-172-31-10-167 ~]# ~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --verify --verbose

ERROR: No metrics specified for collection and submission to CloudWatch.

For more information, run 'mon-put-instance-data.pl --help'

I've followed the prerequisite in the documentation to ensure that all required tools are installed first. What did I miss?

Kelvin Low
  • 678
  • 1
  • 10
  • 23

3 Answers3

3

I think what you need is:

~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-used

--mem-used flag will tell the script that you want memory used and --mem-used-incl-cache-buff tells it to include cache and buffers.

To verify this you can run these 2 commands and compare the output:

~/aws-scripts-mon/mon-put-instance-data.pl --mem-used --verify --verbose
~/aws-scripts-mon/mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-used --verify --verbose
Dejan Peretin
  • 10,891
  • 1
  • 45
  • 54
0

I use this in my custom metrics. As mentioned by @Tartaglia, you need to enable the mem-used switch to report memory statistics. You can view the Perl script and see how this is computed.

Without buffers and cache:

mon-put-instance-data.pl --mem-used

Output:

Payload:{"MetricData":[{"MetricName":"MemoryUsed","Unit":"Megabytes","Value":4915.6640625,"Timestamp":1501356451}

With buffers and cache:

mon-put-instance-data.pl --mem-used-incl-cache-buff --mem-used

Output:

Payload:{"MetricData":[{"MetricName":"MemoryUsed","Unit":"Megabytes","Value":5690.55078125,"Timestamp":1501356486}
helloV
  • 50,176
  • 7
  • 137
  • 145
-1

Try something like this:

If you want to send custom data

/usr/local/bin/aws cloudwatch put-metric-data \
  --namespace "TomcatOpenFiles" \
  --dimensions INSTANCE_ID="`curl -s http://169.254.169.254/latest/meta-data/instance-id`" \
  --metric-name "TomcatOpenFiles" \
  --value $Tomcat_Openfiles \
  --region ap-south-1

Note: 169.254.169.254 is where you can retrieve instance metadata as documented here

If you want to send AWS defined data

/opt/aws-scripts-mon/mon-put-instance-data.pl \
  --mem-util \
  --mem-used \
  --mem-avail \
  --disk-space-util \
  --disk-space-used \
  --disk-space-avail \
  --memory-units=gigabytes \
  --disk-space-units=gigabytes \
  --disk-path=/ \
  --from-cron
GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
Deepak Singhal
  • 10,568
  • 11
  • 59
  • 98