{"id":828,"date":"2017-01-21T07:25:41","date_gmt":"2017-01-20T22:25:41","guid":{"rendered":"http:\/\/blue-bear.jp\/kb\/?p=828"},"modified":"2018-11-25T23:53:37","modified_gmt":"2018-11-25T14:53:37","slug":"aws-ec2%e3%82%a4%e3%83%b3%e3%82%b9%e3%82%bf%e3%83%b3%e3%82%b9%e3%81%ae%e3%83%a1%e3%83%a2%e3%83%aa%e3%82%84%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e4%bd%bf%e7%94%a8%e9%87%8f%e3%82%92cloudwatch%e3%81%ab","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/aws-ec2%e3%82%a4%e3%83%b3%e3%82%b9%e3%82%bf%e3%83%b3%e3%82%b9%e3%81%ae%e3%83%a1%e3%83%a2%e3%83%aa%e3%82%84%e3%83%87%e3%82%a3%e3%82%b9%e3%82%af%e4%bd%bf%e7%94%a8%e9%87%8f%e3%82%92cloudwatch%e3%81%ab\/","title":{"rendered":"[AWS] EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30e2\u30ea\u3084\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u91cf\u3092CloudWatch\u306b\u9001\u4fe1\u3059\u308b"},"content":{"rendered":"<h2>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30e2\u30ea\u3084\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u91cf\u3092CloudWatch\u306b\u9001\u4fe1\u3059\u308b<\/h2>\n<p>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\uff08Amazon Linux AMI\uff09\u306e\u30e1\u30e2\u30ea\u3084\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u91cf\u3092CloudWatch\u306b\u9001\u4fe1\u3059\u308b\u306b\u306f\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u8a2d\u5b9a\u3059\u308b<\/p>\n<h3>\u5fc5\u8981\u306aPerl\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>\u63d0\u4f9b\u3055\u308c\u308b\u30c4\u30fc\u30eb\u306fPerl\u3067\u52d5\u4f5c\u3059\u308b\u306e\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8ffd\u52a0\u3059\u308b<\/p>\n<pre>sudo yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https --nogpgcheck\r\n<\/pre>\n<p>GPG\u9375\u304c\u53d6\u5f97\u3067\u304d\u306a\u3044\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u306e\u3067\u5bfe\u51e6\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"yfPTN8trWq\"><p><a href=\"https:\/\/blue-bear.jp\/kb\/aws-yum-install%e3%81%a7gpg%e9%8d%b5%e3%81%8c%e5%8f%96%e5%be%97%e3%81%a7%e3%81%8d%e3%81%be%e3%81%9b%e3%82%93%e3%81%a7%e3%81%97%e3%81%9f%e3%82%a8%e3%83%a9%e3%83%bc\/\">[AWS] yum install\u3067GPG\u9375\u304c\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u30a8\u30e9\u30fc<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;[AWS] yum install\u3067GPG\u9375\u304c\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u30a8\u30e9\u30fc&#8221; &#8212; Bluebear I\/O\" src=\"https:\/\/blue-bear.jp\/kb\/aws-yum-install%e3%81%a7gpg%e9%8d%b5%e3%81%8c%e5%8f%96%e5%be%97%e3%81%a7%e3%81%8d%e3%81%be%e3%81%9b%e3%82%93%e3%81%a7%e3%81%97%e3%81%9f%e3%82%a8%e3%83%a9%e3%83%bc\/embed\/#?secret=yfPTN8trWq\" data-secret=\"yfPTN8trWq\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u3082\u3057Perl\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u306a\u3044Can&#8217;t locate xxx.pm\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408\u306f<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"4JDsguEyXK\"><p><a href=\"https:\/\/blue-bear.jp\/kb\/aws-perl%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%81%8c%e8%a6%8b%e5%bd%93%e3%81%9f%e3%82%89%e3%81%aa%e3%81%84cant-locate-xxx-pm%e3%82%a8%e3%83%a9%e3%83%bc\/\">[AWS] Perl\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u898b\u5f53\u305f\u3089\u306a\u3044(Can&#8217;t locate xxx.pm\u30a8\u30e9\u30fc)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;[AWS] Perl\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u898b\u5f53\u305f\u3089\u306a\u3044(Can&#8217;t locate xxx.pm\u30a8\u30e9\u30fc)&#8221; &#8212; Bluebear I\/O\" src=\"https:\/\/blue-bear.jp\/kb\/aws-perl%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%81%8c%e8%a6%8b%e5%bd%93%e3%81%9f%e3%82%89%e3%81%aa%e3%81%84cant-locate-xxx-pm%e3%82%a8%e3%83%a9%e3%83%bc\/embed\/#?secret=4JDsguEyXK\" data-secret=\"4JDsguEyXK\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u3082\u3057\u304f\u306f\u3082\u3046\u4e00\u5ea6\u4e0a\u306eyum install\u3067\u5168\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u307f\u308b<\/p>\n<p>&nbsp;<\/p>\n<h4>Bitnami\u3067\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8ffd\u52a0\u3059\u308b<\/h4>\n<pre class=\"lang:default decode:true\">sudo apt-get install libwww-perl libdatetime-perl<\/pre>\n<p>&nbsp;<\/p>\n<h3>\u30e2\u30cb\u30bf\u30ea\u30f3\u30b0\u30c4\u30fc\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b<\/h3>\n<p>AMAZON\u304b\u3089\u63d0\u4f9b\u3055\u308c\u3066\u3044\u308bcloudwatch\u7528\u30c4\u30fc\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3001\u89e3\u51cd<\/p>\n<pre class=\"\">curl http:\/\/aws-cloudwatch.s3.amazonaws.com\/downloads\/CloudWatchMonitoringScripts-1.2.2.zip -O\r\nunzip CloudWatchMonitoringScripts-1.2.2.zip\r\nrm CloudWatchMonitoringScripts-1.2.2.zip\r\ncd aws-scripts-mon\r\n<\/pre>\n<h3>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u30fb\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc<\/h3>\n<p>AWS\u30b3\u30f3\u30bd\u30fc\u30eb\u306eIAM\u30b5\u30fc\u30d3\u30b9\u304b\u3089Monitor\u7528\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210\u3057\u3001\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u30fb\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u3092\u53d6\u5f97<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-832\" src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.15.55.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 7.15.55\" width=\"1854\" height=\"362\" srcset=\"https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.15.55.png 1854w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.15.55-300x59.png 300w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.15.55-768x150.png 768w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.15.55-1024x200.png 1024w\" sizes=\"(max-width: 1854px) 100vw, 1854px\" \/><\/p>\n<p>\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u306f\u4e00\u5ea6\u3057\u304b\u8868\u793a\u3055\u308c\u306a\u3044\u306e\u3067\u6ce8\u610f<\/p>\n<p>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u30fb\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc\u3092\u53d6\u5f97\u3057\u305f\u3089\u3001\u5148\u7a0b\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305faws-scripts-mon\u30d5\u30a9\u30eb\u30c0\u4e0a\u306b\u3042\u308bawscreds.template\u306b\u8ffd\u8a18\u3057\u307e\u3059<\/p>\n<pre>vi .\/awscreds.template\r\n<\/pre>\n<pre>AWSAccessKeyId=xxxxxxxxxxxxxxxx(\u30a2\u30af\u30bb\u30b9\u30ad\u30fc)\r\nAWSSecretKey=xxxxxxxxxxxxxxxx(\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u30ad\u30fc)\r\n<\/pre>\n<p>awscreds.template\u3067\u306f\u52d5\u4f5c\u3057\u306a\u3044\u306e\u3067awscreds.conf\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u30b3\u30d4\u30fc<\/p>\n<pre>cp awscreds.template awscreds.conf\r\n<\/pre>\n<p>\u30b3\u30d4\u30fc\u3057\u5fd8\u308c\u308b\u3068<br \/>\nERROR: No IAM role is associated with this EC2 instance.<br \/>\n\u3068\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b<\/p>\n<h3>\u8d77\u52d5\u78ba\u8a8d<\/h3>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u52d5\u4f5c\u3059\u308b\u304b\u78ba\u8a8d\u3059\u308b<\/p>\n<pre>.\/mon-put-instance-data.pl --mem-util --mem-used --mem-avail\r\n<\/pre>\n<p>Successfully reported metrics to CloudWatch. \u3068\u8868\u793a\u3055\u308c\u308c\u3070\u6210\u529f<\/p>\n<p>&nbsp;<\/p>\n<p>\u3082\u3057\u300cCan&#8217;t locate Digest\/SHA.pm\u300d\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306f<\/p>\n<pre class=\"lang:default decode:true \">sudo yum install -y perl-Digest-SHA<\/pre>\n<p>&nbsp;<\/p>\n<h3>Cron\u8a2d\u5b9a<\/h3>\n<p>\u3042\u3068\u306f\u5b9a\u671f\u7684\u306bCloudWatch\u306b\u30c7\u30fc\u30bf\u3092\u9001\u308bCron\u3092\u8a2d\u5b9a\u3059\u308c\u3070\u3088\u3044<br \/>\ncrontab -e\u3067cron\u3092\u7de8\u96c6<\/p>\n<pre>*\/5 * * * * ~\/aws-scripts-mon\/mon-put-instance-data.pl --mem-util --disk-space-util --disk-path=\/ --from-cron\r\n<\/pre>\n<p>\uff0a\u30e1\u30e2\u30ea\u4f7f\u7528\u7387\u3001\u30c7\u30a3\u30b9\u30af\u4f7f\u7528\u7387\u3092CloudWatch\u306b\u9001\u4fe1<\/p>\n<p>Cron\u3067\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u304b\u3092\u5ff5\u306e\u305f\u3081\u78ba\u8a8d<\/p>\n<pre>cat \/var\/log\/cron\r\n<\/pre>\n<h3>CloudWatch\u4e0a\u306b\u767b\u9332<\/h3>\n<p>\u30a2\u30e9\u30fc\u30e0\u3092\u8a2d\u5b9a\u3059\u308b\u304c\u3001\u53d6\u5f97\u3057\u305f\u5024\u306fLinux\u30b7\u30b9\u30c6\u30e0\u30e1\u30c8\u30ea\u30c3\u30af\u30b9\u6b04\u306b\u8ffd\u52a0\u3055\u308c\u3066\u3044\u308b<br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5225\u6b04\u306b\u306f\u8ffd\u52a0\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u6ce8\u610f<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-834\" src=\"http:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.13.24.png\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2017-01-21 7.13.24\" width=\"646\" height=\"250\" srcset=\"https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.13.24.png 646w, https:\/\/blue-bear.jp\/kb\/wp-content\/uploads\/2017\/01\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2017-01-21-7.13.24-300x116.png 300w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/p>\n<h3>\u672c\u5bb6\u30de\u30cb\u30e5\u30a2\u30eb<\/h3>\n<p>\u672c\u5bb6\u30de\u30cb\u30e5\u30a2\u30eb\uff08\u53c2\u8003\uff09<br \/>\n<a href=\"http:\/\/docs.aws.amazon.com\/ja_jp\/AWSEC2\/latest\/UserGuide\/mon-scripts.html\" target=\"_blank\">http:\/\/docs.aws.amazon.com\/ja_jp\/AWSEC2\/latest\/UserGuide\/mon-scripts.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30e2\u30ea\u3084\u30c7\u30a3\u30b9\u30af\u4f7f\u7528<\/p>\n","protected":false},"author":1,"featured_media":834,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[105,107,106,109,108],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/828"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=828"}],"version-history":[{"count":11,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/828\/revisions"}],"predecessor-version":[{"id":1785,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/828\/revisions\/1785"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media\/834"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}