Created
March 14, 2013 15:53
-
-
Save anonymous/5162531 to your computer and use it in GitHub Desktop.
Cloud Watch Monitoring Scripts using Chef.
Monitors Memory and Disk usage.
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
### Monitor Memory and Disk utilization with CloudWatch | |
### Assume that the instance have a IAMRole with CloudWath PutMetricData | |
### http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/mon-scripts-perl.html | |
%w{ unzip libwww-perl libcrypt-ssleay-perl }.each do |pkg| | |
package pkg do | |
action :install | |
end | |
end | |
remote_file "/opt/CloudWatchMonitoringScripts-v1.1.0.zip" do | |
source "http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip" | |
action :create_if_missing | |
notifies :run, "bash[unzip-cloud-watch]", :immediately | |
notifies :create, "cron[cloud-watch-memory]", :immediately | |
notifies :create, "cron[cloud-watch-disk]", :immediately | |
end | |
bash "unzip-cloud-watch" do | |
code <<-EOF | |
cd /opt | |
unzip CloudWatchMonitoringScripts-v1.1.0.zip | |
EOF | |
action :nothing | |
end | |
cron "cloud-watch-memory" do | |
minute "*/1" | |
user "root" | |
shell "/bin/bash" | |
command "/opt/aws-scripts-mon/mon-put-instance-data.pl --mem-util --mem-used --mem-avail --memory-units=megabytes --from-cron" | |
action :nothing | |
end | |
cron "cloud-watch-disk" do | |
minute "*/5" | |
user "root" | |
shell "/bin/bash" | |
command "/opt/aws-scripts-mon/mon-put-instance-data.pl --disk-space-used --disk-space-avail --disk-space-util --disk-path=/ --disk-space-units=gigabytes --from-cron" | |
action :nothing | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment