Forked from martinzuern/UserData script for setup CloudWatch
Last active
September 21, 2020 12:46
-
-
Save serkanh/51e4bebb63836c55d71a6791b0135a2c to your computer and use it in GitHub Desktop.
With this user data script, you can set up cron job to put some custom metrics for CloudWatch at instance initiation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
yum install -y perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https perl-Digest-SHA unzip | |
cd /home/ec2-user | |
curl http://aws-cloudwatch.s3.amazonaws.com/downloads/CloudWatchMonitoringScripts-1.2.1.zip -O | |
unzip CloudWatchMonitoringScripts-1.2.1.zip | |
rm -rf CloudWatchMonitoringScripts-1.2.1.zip | |
chown ec2-user:ec2-user aws-scripts-mon | |
echo "* * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --mem-util --swap-util --aggregated --auto-scaling --from-cron" >> /var/spool/cron/ec2-user | |
echo "0 * * * * /home/ec2-user/aws-scripts-mon/mon-put-instance-data.pl --disk-space-used --disk-space-avail --disk-space-util --disk-path=/ --aggregated --auto-scaling --from-cron" >> /var/spool/cron/ec2-user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment