Skip to content

Instantly share code, notes, and snippets.

@nojimage
Created April 25, 2014 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nojimage/11276400 to your computer and use it in GitHub Desktop.
Save nojimage/11276400 to your computer and use it in GitHub Desktop.
AWSのメモリとかディスク容量とかをモニタリング出来るようにするスクリプトのセットアップ的なアレ
# install require packages
sudo yum install -y perl-Switch perl-Sys-Syslog perl-LWP-Protocol-https
# download and extract
curl -LO http://ec2-downloads.s3.amazonaws.com/cloudwatch-samples/CloudWatchMonitoringScripts-v1.1.0.zip
mkdir ~/cloudwatch
test -f ~/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl || unzip CloudWatchMonitoringScripts-v1.1.0.zip -d ~/cloudwatch/
rm CloudWatchMonitoringScripts-v1.1.0.zip
# create credentials file
echo "AWSAccessKeyId=YOUR_ACCESS_KEY" > ~/cloudwatch/aws-scripts-mon/awscreds.conf
echo "AWSSecretKey=YOUR_ACCESS_SECRET_KEY" >> ~/cloudwatch/aws-scripts-mon/awscreds.conf
chmod 0600 ~/cloudwatch/aws-scripts-mon/awscreds.conf
# test
# ~/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl --mem-util --swap-util --disk-space-util --disk-path=/ --aws-credential-file=/home/ec2-user/cloudwatch/aws-scripts-mon/awscreds.conf --verbose
# register cron each 5min
cronjob="*/5 * * * * ${HOME}/cloudwatch/aws-scripts-mon/mon-put-instance-data.pl --mem-util --swap-util --disk-space-util --disk-path=/ --aws-credential-file=${HOME}/cloudwatch/aws-scripts-mon/awscreds.conf --from-cron"
test $(crontab -l | grep "mon-put-instance-data.pl" | wc -l) -gt 0 || crontab -l | { cat; echo "$cronjob"; } | crontab -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment