{"id":5297,"date":"2017-02-15T00:01:57","date_gmt":"2017-02-14T15:01:57","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=5297"},"modified":"2017-02-24T08:55:15","modified_gmt":"2017-02-23T23:55:15","slug":"check_error_log_count_each_ip","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/check_error_log_count_each_ip.html","title":{"rendered":"Apache Web\u30b5\u30fc\u30d0\u306e\u30a8\u30e9\u30fc\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a8\u30e9\u30fc\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5e\u30b5\u30fc\u30d0\u30fc\u3084\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8106\u5f31\u6027\u3092\u72d9\u3063\u305f\u30b5\u30a4\u30d0\u30fc\u653b\u6483\u3001Dos\u653b\u6483\u3001WordPress\u7b49\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3078\u306e\u653b\u6483\u691c\u77e5\u306b\u3082\u4f7f\u3048\u308b\u30a8\u30e9\u30fc\u96c6\u8a08\uff5e"},"content":{"rendered":"

\u524d\u56de\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067Apache\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n

\u53c2\u8003\u8a18\u4e8b\uff1aApache 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<\/a><\/p>\n

\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u306b\u52a0\u3048\u3066\u3001Web\u30b5\u30fc\u30d0\u3092\u904b\u7528\u3059\u308b\u4e0a\u3067\u3069\u306e\u3088\u3046\u306aIP\u304b\u3089\u306e\u30a2\u30af\u30bb\u30b9\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u3044\u308b\u304b\u3092\u77e5\u3063\u3066\u304a\u304f\u3053\u3068\u3082\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\u3001Web\u30b5\u30fc\u30d0\u3067\u767a\u751f\u3057\u305f\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u5206\u6790\u3059\u308b\u6a5f\u80fd\u3092\u6301\u3061\u5408\u308f\u305b\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u5c11\u306a\u3044\u3067\u3057\u3087\u3046\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\u3067\u767a\u751f\u3057\u305f\u30a8\u30e9\u30fc\u306fWeb\u30b5\u30fc\u30d0\u306e\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u76f4\u63a5\u53c2\u7167\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u3055\u3089\u306b\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u5b9a\u671f\u7684\u306b\u76e3\u8996\u3059\u308b\u3053\u3068\u306f\u30b5\u30fc\u30d0\u30fc\u3084\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8106\u5f31\u6027\u3092\u72d9\u3063\u305f\u30b5\u30a4\u30d0\u30fc\u653b\u6483\u3001Dos\u653b\u6483\u3001Wordpress\u7b49\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3078\u306e\u653b\u6483\u306b\u6c17\u3065\u304f\u3053\u3068\u306b\u3082\u7e4b\u304c\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\u30a8\u30e9\u30fc\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a8\u30e9\u30fc\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\u30a8\u30e9\u30fc\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a8\u30e9\u30fc\u6570\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5e\u30b5\u30fc\u30d0\u30fc\u3084\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306e\u8106\u5f31\u6027\u3092\u72d9\u3063\u305f\u30b5\u30a4\u30d0\u30fc\u653b\u6483\u3001Dos\u653b\u6483\u3001Wordpress\u7b49\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3078\u306e\u653b\u6483\u691c\u77e5\u306b\u3082\u4f7f\u3048\u308b\u30a8\u30e9\u30fc\u96c6\u8a08\uff5e<\/h2>\n

\u57fa\u672c\u65b9\u91dd\u3068\u3057\u3066\u306f\u30a8\u30e9\u30fc\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\u30a8\u30e9\u30fc\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a8\u30e9\u30fc\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

\u307e\u305f\u3001\u300call\u300d\u3092\u5f15\u6570\u306b\u3059\u308b\u3068\u5168\u3066\u306e\u65e5\u4ed8\u306b\u5bfe\u3057\u3066\u96c6\u8a08\u3092\u304b\u3051\u308b\u3053\u3068\u304c\u3067\u304d\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_error_log_count_each_ip.sh\r\n<\/pre>\n
\r\n#!\/bin\/bash\r\n\r\n#\u30a8\u30e9\u30fc\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9\r\nLOG_PATH=\/var\/log\/httpd\/error_log\r\n\r\n#\u5f15\u6570\u53d6\u5f97\r\ntarget=${1}\r\n\r\nif [ "${target}" = "all" ]; then\r\n  #\u5f15\u6570\u304call\u3067\u3042\u308c\u3070\u5168\u3066\u306e\u65e5\u4ed8\u3092\u6307\u5b9a\r\n  target=all\r\nelif [ "${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\nif [ "${target}" = "all" ]; then\r\n  #\u5168\u65e5\u6307\u5b9a\u3067\u3042\u308c\u3070\u65e5\u4ed8\u6307\u5b9a\u7121\u3057\r\n  APACHE_DATE=""\r\nelse\r\n  #\u96c6\u8a08\u5bfe\u8c61\u306e\u65e5\u4ed8\u6587\u5b57\u5217\u3092\u4f5c\u6210\r\n  APACHE_DATE=`${DATECMD} "+%a %b %d" --utc --date "${target} day ago"`\r\nfi\r\n\r\n#\u6539\u884c\u3078\u306e\u5909\u63db\u3092\u884c\u3046\u305f\u3081\u306e\u6539\u884c\u30b3\u30fc\u30c9\u3092\u6307\u5b9a\u3002\r\nLF=$'\\\\\\x0A'\r\n\r\n#\u30a8\u30e9\u30fc\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} " | grep client | sed 's\/[^0-9.]\/'"$LF"'\/g' | grep '^[0-9]' | sed 's\/^\\.\/\/g' | sed 's\/\\.$\/\/g' | grep '[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*' | sort -n | uniq -c | sort -n\r\n\r\n<\/pre>\n

Apache Web\u30b5\u30fc\u30d0\u306e\u30a8\u30e9\u30fc\u30ed\u30b0\u304b\u3089\u65e5\u5225\u3001\u30db\u30b9\u30c8\u540d\u30fbIP\u30a2\u30c9\u30ec\u30b9\u6bce\u306b\u30a8\u30e9\u30fc\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\u306ball\u3092\u6307\u5b9a\u3057\u3066\u5b58\u5728\u3059\u308b\u30a8\u30e9\u30fc\u30ed\u30b0\u5168\u3066\u306e\u65e5\u4ed8\u306b\u5bfe\u3057\u3066\u30a8\u30e9\u30fc\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

\u3053\u306e\u4f8b\u3067\u3042\u308c\u3070\u300c123.456.789.016\u300d\u300c123.456.789.015\u300d\u306a\u3069\u30a8\u30e9\u30fc\u6570\u304c\u591a\u3044IP\u30a2\u30c9\u30ec\u30b9\u306f\u4f55\u3089\u304b\u306e\u653b\u6483\u3092\u4ed5\u639b\u3051\u3066\u3044\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u306e\u3067\u3001\u518d\u5ea6\u30a8\u30e9\u30fc\u30ed\u30b0\u3092\u691c\u7d22\u3057\u3066\u4e0d\u6b63\u30a2\u30af\u30bb\u30b9\u304c\u306a\u3044\u304b\u78ba\u8a8d\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n

\r\n[magtranetwork@localhost ~]# chmod 755 check_error_log_count_each_ip.sh\r\n[magtranetwork@localhost ~]# .\/check_error_log_count_each_ip.sh 1\r\n      1 123.456.789.001\r\n      1 123.456.789.002\r\n      1 123.456.789.003\r\n      1 123.456.789.004\r\n      1 123.456.789.005\r\n      2 123.456.789.006\r\n      2 123.456.789.007\r\n\uff5e\u7701\u7565\uff5e\r\n      3 123.456.789.008\r\n      3 123.456.789.009\r\n      3 123.456.789.010\r\n      3 123.456.789.011\r\n      3 123.456.789.012\r\n      6 123.456.789.013\r\n      6 123.456.789.014\r\n     11 123.456.789.015\r\n     24 123.456.789.016\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u524d\u56de\u3001\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067Apache\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u96c6\u8a08\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002 \u53c2\u8003\u8a18\u4e8b\uff1aApache 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 […]<\/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\/5297"}],"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=5297"}],"version-history":[{"count":4,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5297\/revisions"}],"predecessor-version":[{"id":5339,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5297\/revisions\/5339"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=5297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=5297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=5297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}