{"id":5290,"date":"2017-02-14T00:01:27","date_gmt":"2017-02-13T15:01:27","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=5290"},"modified":"2017-02-24T08:52:19","modified_gmt":"2017-02-23T23:52:19","slug":"check_access_log_count_each_ip","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/check_access_log_count_each_ip.html","title":{"rendered":"Apache Web\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5eJavaScript\u304c\u52d5\u4f5c\u3057\u306a\u3044\u30af\u30ed\u30fc\u30e9\u30fc\u3001\u30b3\u30de\u30f3\u30c9\u3067\u306e\u30a2\u30af\u30bb\u30b9\u306b\u3082\u5bfe\u5fdc\u3057\u305f\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u3044\u305f\u96c6\u8a08\u65b9\u6cd5\uff5e"},"content":{"rendered":"

Web\u30b5\u30fc\u30d0\u3092\u904b\u7528\u3059\u308b\u4e0a\u3067\u3069\u306e\u3088\u3046\u306aIP\u304b\u3089\u3069\u306e\u3088\u3046\u306a\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308b\u304b\u3092\u77e5\u3063\u3066\u304a\u304f\u3053\u3068\u306f\u91cd\u8981\u306a\u4e8b\u3067\u3059\u3002<\/p>\n

\u6700\u8fd1\u3067\u306fGoogle\u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306a\u3069\u9ad8\u6027\u80fd\u306a\u30c4\u30fc\u30eb\u3067\u30a6\u30a7\u30d6\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u5206\u6790\u3092\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3057\u305f\u304c\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u6bce\u306b\u8a73\u7d30\u306b\u898b\u3066\u3044\u304f\u5834\u5408\u306f\u3084\u306f\u308aWeb\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u76f4\u63a5\u96c6\u8a08\u3059\u308b\u3053\u3068\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n

\u7279\u306bJavaScript\u304c\u52d5\u4f5c\u3057\u306a\u3044\u30af\u30ed\u30fc\u30e9\u30fc\u3084Curl\u3001Wget\u306a\u3069\u306e\u30b3\u30de\u30f3\u30c9\u3067\u306e\u30a2\u30af\u30bb\u30b9\u306fWeb\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u76f4\u63a5\u53c2\u7167\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u4eca\u56de\u306f\u30af\u30ed\u30fc\u30e9\u30fc\u3084\u30b3\u30de\u30f3\u30c9\u306a\u3069\u306e\u30a6\u30a7\u30d6\u30d6\u30e9\u30a6\u30b6\u4ee5\u5916\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3082\u542b\u3093\u3060Web\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n

Apache Web\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5eJavaScript\u304c\u52d5\u4f5c\u3057\u306a\u3044\u30af\u30ed\u30fc\u30e9\u30fc\u3001\u30b3\u30de\u30f3\u30c9\u3067\u306e\u30a2\u30af\u30bb\u30b9\u306b\u3082\u5bfe\u5fdc\u3057\u305f\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u3044\u305f\u96c6\u8a08\u65b9\u6cd5\uff5e<\/h2>\n

\u57fa\u672c\u65b9\u91dd\u3068\u3057\u3066\u306f\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\u306b\u300c*\u300d\u3092\u4ed8\u3051\u3066\u30ed\u30b0\u30ed\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3082\u542b\u3081\u3066\u65e5\u4ed8\u6307\u5b9a\u3067\u96c6\u8a08\u3057\u307e\u3059\u3002<\/p>\n

Apache Web\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)<\/h3>\n

\u5f15\u6570\u306b\u6574\u6570\u3092\u5165\u529b\u3059\u308b\u3053\u3068\u3067\u5f53\u65e5\u304b\u3089\u6570\u3048\u3066\u5f15\u6570\u306e\u65e5\u6570\u524d\u306e\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\u96c6\u8a08\u3057\u305f\u7d50\u679c\u306f\u30a2\u30af\u30bb\u30b9\u6570\u304c\u5c11\u306a\u3044\u9806\u306b\u30bd\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u3066\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n

\r\nvim check_access_log_count_each_ip.sh\r\n<\/pre>\n
\r\n#!\/bin\/bash\r\n\r\n#\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\nLOG_PATH=\/var\/log\/httpd\/access_log\r\n\r\n#\u5f15\u6570\u53d6\u5f97\r\ntarget=${1}\r\n\r\nif [ "${target}" = "" ]; then\r\n  #\u5f15\u6570\u304c\u306a\u3051\u308c\u3070\u5f53\u65e5\u3092\u6307\u5b9a\r\n  target=0\r\nelif [[ ! "${target}" =~ ^[0-9]*$ ]]; then\r\n  #\u5f15\u6570\u304c\u3042\u308a\u3001\u6574\u6570\u3067\u3042\u308c\u3070\u5f15\u6570\u306e\u65e5\u6570\u524d\u3092\u6307\u5b9a\r\n  target=0\r\nfi\r\n\r\nexport LANG=en_US.UTF-8\r\n\r\n#macOS\u306fgdate\u30b3\u30de\u30f3\u30c9\u3067\u65e5\u4ed8\u3092\u51fa\u529b\r\nif [ "$(uname)" == 'Darwin' ]; then\r\n  DATECMD=gdate\r\nelse\r\n  DATECMD=date\r\nfi\r\n\r\n#\u96c6\u8a08\u5bfe\u8c61\u306e\u65e5\u4ed8\u6587\u5b57\u5217\u3092\u4f5c\u6210\r\nAPACHE_DATE=`${DATECMD} "+%d\/%b\/%Y" --date "${target} day ago"`\r\n\r\n#\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u306e\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306e\u96c6\u8a08\u51e6\u7406\r\ncat ${LOG_PATH}* | egrep "\\[${APACHE_DATE}:" | awk '{print $1}' | sort | uniq -c | sort -n\r\n\r\n<\/pre>\n

Apache Web\u30b5\u30fc\u30d0\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a2\u30af\u30bb\u30b9\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)<\/h3>\n

\u5f15\u6570\u306b1\u3092\u6307\u5b9a\u3057\u30661\u65e5\u524d\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u306e\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306e\u96c6\u8a08\u3092\u8a08\u7b97\u3057\u3066\u3044\u308b\u4f8b\u3067\u3059\u3002<\/p>\n

\u5b9f\u884c\u7d50\u679c\u306e\u5185\u5bb9\u306f\u3042\u304f\u307e\u3067\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n

\r\n[magtranetwork@localhost ~]# chmod 755 check_access_log_count_each_ip.sh\r\n[magtranetwork@localhost ~]# .\/check_access_log_count_each_ip.sh 1\r\n      1 0.abc.defgh.ijklm.magtranetwork.net\r\n      1 987.654.321.012\r\n      2 magtranetwork.com\r\n      3 234.567.89.012\r\n      3 123-456-789-01a1.bcd2.magtranetwork.com\r\n\uff5e\u7701\u7565\uff5e\r\n   8335 crawl-12-345-678-012.magtranetwork.com\r\n   8352 12-345-6-78.aiu.magtranetwork.com\r\n   8777 123.456.789.01.ai.magtranetwork.com\r\n   9002 345.678.9.01\r\n  18833 12.34.567.890.bc.magtranetwork.com\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Web\u30b5\u30fc\u30d0\u3092\u904b\u7528\u3059\u308b\u4e0a\u3067\u3069\u306e\u3088\u3046\u306aIP\u304b\u3089\u3069\u306e\u3088\u3046\u306a\u30a2\u30af\u30bb\u30b9\u304c\u3042\u308b\u304b\u3092\u77e5\u3063\u3066\u304a\u304f\u3053\u3068\u306f\u91cd\u8981\u306a\u4e8b\u3067\u3059\u3002 \u6700\u8fd1\u3067\u306fGoogle\u30a2\u30ca\u30ea\u30c6\u30a3\u30af\u30b9\u306a\u3069\u9ad8\u6027\u80fd\u306a\u30c4\u30fc\u30eb\u3067\u30a6\u30a7\u30d6\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u5206\u6790\u3092\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3057\u305f\u304c […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3,22,79,82],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5290"}],"collection":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/comments?post=5290"}],"version-history":[{"count":2,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5290\/revisions"}],"predecessor-version":[{"id":5337,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5290\/revisions\/5337"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=5290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=5290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=5290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}