Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(monitoring): add memory monitoring to EC2 instances #620

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions .ebextensions/eb-memory-monitor.config
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
###################################################################################################
#### Memory monitoring for Elastic Beanstalk
#### https://medium.com/tomincode/cloudwatch-memory-monitoring-for-elastic-beanstalk-1caa98d57d5c
#### https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-memory-monitoring/
###################################################################################################

packages:
yum:
perl-DateTime: []
perl-Sys-Syslog: []
perl-LWP-Protocol-https: []
perl-Switch: []
perl-URI: []
perl-Bundle-LWP: []
liangyuanruo marked this conversation as resolved.
Show resolved Hide resolved
sources:
/opt/cloudwatch: https://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip

container_commands:
00download:
command: "wget http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.2.zip"
ignoreErrors: true
01extract:
command: "unzip -o CloudWatchMonitoringScripts-1.2.2.zip"
ignoreErrors: true
02rmzip:
command: "rm CloudWatchMonitoringScripts-1.2.2.zip"
ignoreErrors: true
03prereq:
command: "yum install -y perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https"
ignoreErrors: false
04cdinto:
command: "mv aws-scripts-mon/ /home/ec2-user"
ignoreErrors: true
05cron:
command: "crontab -l | grep -q 'mon-put-instance-data.pl' || crontab -l | { cat; echo '* * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --mem-used --mem-avail'; } | crontab -"
ignoreErrors: false
01-setupcron:
command: |
echo '*/5 * * * * root perl /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl `{"Fn::GetOptionSetting" : { "OptionName" : "CloudWatchMetrics", "DefaultValue" : "--mem-util --disk-space-util --disk-path=/" }}` >> /var/log/cwpump.log 2>&1' > /etc/cron.d/cwpump
02-changeperm:
command: chmod 644 /etc/cron.d/cwpump
03-changeperm:
command: chmod u+x /opt/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl
option_settings:
"aws:autoscaling:launchconfiguration" :
IamInstanceProfile : "aws-elasticbeanstalk-ec2-role"
"aws:elasticbeanstalk:customoption" :
CloudWatchMetrics : "--mem-util --mem-used --mem-avail --disk-space-util --disk-space-used --disk-space-avail --disk-path=/ --auto-scaling"