{"id":5235,"date":"2017-02-09T00:01:06","date_gmt":"2017-02-08T15:01:06","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=5235"},"modified":"2017-02-08T12:55:26","modified_gmt":"2017-02-08T03:55:26","slug":"website_api_response_time","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/website_api_response_time.html","title":{"rendered":"\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8(Web\u30b5\u30fc\u30d0)\u306e\u30da\u30fc\u30b8\u5358\u4f4d\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u30fb\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6(\u8868\u793a\u30b9\u30d4\u30fc\u30c9)\u3092\u6e2c\u5b9a\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5eAPI\u30b5\u30fc\u30d0\u306ePOST\u30e1\u30bd\u30c3\u30c9\u306e\u5fdc\u7b54\u6642\u9593\u8a08\u6e2c\u306b\u3082\u4f7f\u7528\u3067\u304d\u308b\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u5f0f\u306e\u6e2c\u5b9a\u30c4\u30fc\u30eb\uff5e"},"content":{"rendered":"

\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u3092\u59cb\u3081\u3068\u3059\u308b\u30b9\u30de\u30fc\u30c8\u30c7\u30d0\u30a4\u30b9\u306e\u666e\u53ca\u3084\u30e2\u30ce\u3092\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3067\u7e4b\u3050IoT\u306e\u958b\u767a\u304c\u6d3b\u767a\u5316\u3057\u3066\u304d\u305f\u6700\u8fd1\u3067\u306f\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u30fb\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6\u306f\u3055\u3089\u306b\u91cd\u8981\u306a\u8981\u7d20\u3068\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n

\u4e00\u822c\u7684\u306aGET\u30e1\u30bd\u30c3\u30c9\u3067\u8868\u793a\u3092\u3057\u3066\u3044\u308b\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306b\u3064\u3044\u3066\u306fJavaScript\u3092\u542b\u3081\u305f\u8868\u793a\u901f\u5ea6\u3092\u8a08\u6e2c\u3059\u308b\u30b5\u30a4\u30c8\u304c\u591a\u304f\u767b\u5834\u3057\u3066\u304a\u308a\u3001\u305d\u308c\u3089\u306e\u30b5\u30a4\u30c8\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u3092\u8a08\u6e2c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n

\u4e00\u65b9\u3067\u30a6\u30a7\u30d6\u30d6\u30e9\u30a6\u30b6\u3067\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3092\u8868\u793a\u3059\u308b\u901f\u5ea6\u3060\u3051\u3067\u306f\u306a\u304f\u3001IoT\u306e\u601d\u60f3\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u306fAPI\u30b5\u30fc\u30d0\u306e\u5fdc\u7b54\u6642\u9593\u3082\u975e\u5e38\u306b\u91cd\u8981\u306b\u306a\u3063\u3066\u304d\u307e\u3059\u3002<\/p>\n

API\u30b5\u30fc\u30d0\u306b\u304a\u3044\u3066\u306fPOST\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u901a\u4fe1\u3092\u63a1\u7528\u3057\u3066\u3044\u308b\u3082\u306e\u3082\u591a\u3044\u305f\u3081\u3001POST\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u5fdc\u3057\u305f\u6e2c\u5b9a\u30c4\u30fc\u30eb\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n

\u4eca\u56de\u306fGET\u30e1\u30bd\u30c3\u30c9\u3001POST\u30e1\u30bd\u30c3\u30c9\u306e\u4e21\u65b9\u306b\u5bfe\u5fdc\u3057\u305f\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u5b9f\u884c\u5f0f\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u30fb\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6(\u8868\u793a\u30b9\u30d4\u30fc\u30c9)\u3092\u6e2c\u5b9a\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

\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8(Web\u30b5\u30fc\u30d0)\u306e\u30da\u30fc\u30b8\u5358\u4f4d\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u30fb\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6(\u8868\u793a\u30b9\u30d4\u30fc\u30c9)\u3092\u6e2c\u5b9a\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0) \uff5eAPI\u30b5\u30fc\u30d0\u306ePOST\u30e1\u30bd\u30c3\u30c9\u306e\u5fdc\u7b54\u6642\u9593\u8a08\u6e2c\u306b\u3082\u4f7f\u7528\u3067\u304d\u308b\u30b3\u30de\u30f3\u30c9\u5b9f\u884c\u5f0f\u306e\u6e2c\u5b9a\u30c4\u30fc\u30eb\uff5e<\/h2>\n

\u57fa\u672c\u65b9\u91dd\u3068\u3057\u3066\u306f\u30e1\u30bd\u30c3\u30c9\u306bGET\u3001POST\u3092\u6307\u5b9a\u3057\u305fcurl\u30b3\u30de\u30f3\u30c9\u3092\u7528\u3044\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n

\u540c\u6642\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3082\u53d6\u5f97\u3067\u304d\u308b\u305f\u3081\u3001\u6b63\u5e38\u306b\u5bfe\u8c61URL\u3068\u901a\u4fe1\u3067\u304d\u305f\u304b\u3082\u78ba\u8a8d\u53ef\u80fd\u3067\u3059\u3002<\/p>\n

\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8(Web\u30b5\u30fc\u30d0)\u306e\u30da\u30fc\u30b8\u5358\u4f4d\u3067\u5fdc\u7b54\u6642\u9593(\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6\u30fb\u8868\u793a\u30b9\u30d4\u30fc\u30c9)\u3092\u6e2c\u5b9a\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)<\/h3>\n

\u7b2c\u4e00\u5f15\u6570\u306b\u30e1\u30bd\u30c3\u30c9\u306e\u6307\u5b9a\u3001\u7b2c\u4e8c\u5f15\u6570\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u6e2c\u5b9a\u5bfe\u8c61\u306eURL\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n

\u306a\u304a\u3001\u4e0b\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306fPOST\u306e\u30d1\u30e9\u30e1\u30bf\u306b\u3064\u3044\u3066\u306f\u7701\u7565\u3057\u3066\u3044\u307e\u3059\u3002\u5fc5\u8981\u3067\u3042\u308c\u3070POST\u30d1\u30e9\u30e1\u30bf\u3092\u6307\u5b9a\u3059\u308b\u5f15\u6570\u3092\u8ffd\u52a0\u3057\u3066\u5bfe\u5fdc\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

\r\n[mag4j@localhost ~]# vim website_response_time.sh\r\n<\/pre>\n
\r\n#!\/bin\/bash\r\n\r\nMETHOD=$1\r\nSITE_URL=$2\r\n\r\n#\u30e1\u30bd\u30c3\u30c9\u306e\u5165\u529b\u5024\u3092\u5927\u6587\u5b57\u306b\u63c3\u3048\u308b\u3002\r\nMETHOD=`echo "${METHOD}" | tr 'a-z' 'A-Z'`\r\n\r\n#GET, POST\u4ee5\u5916\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u5834\u5408\u306f\u4f7f\u7528\u65b9\u6cd5\u3092\u8868\u793a\u3057\u3066\u7d42\u4e86\u3002\r\nif [ "${METHOD}" != "GET" -a "${METHOD}" != "POST" ]; then\r\n  echo "Usage: $(basename $0) [METHOD(GET or POST)] [SITE_URL]"\r\n  exit 1\r\nfi\r\n\r\n#URL\u304cURL\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306e\u6b63\u898f\u8868\u73fe\u306b\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u306f\u7d42\u4e86\u3002\r\nif [[ ! "${SITE_URL}" =~ ^(https?|ftp|s3)(:\\\/\\\/[-_.!~*\\'()a-zA-Z0-9;\\\/?:\\@&=+\\$,%#]+)$ ]]; then\r\n  echo "URL is Invalid Format."\r\n  exit 1\r\nfi\r\n\r\n#\u6b63\u3057\u3044\u30e1\u30bd\u30c3\u30c9\u3001URL\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u6295\u3052\u3001\u30b9\u30bf\u30fc\u30bf\u30b9\u3068\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u3092\u53d6\u5f97\u3059\u308b\u3002\r\nRES=`curl -kL -X "${METHOD}" "${SITE_URL}" -o \/dev\/null -w "{\\"site\\": \\"${SITE_URL}\\", \\"method\\": \\"${METHOD}\\", \\"http_status\\": \\"%{http_code}\\", \\"response_time\\": \\"%{time_total}\\"}\\n" 2> \/dev\/null`\r\n\r\necho ${RES}\r\n\r\n<\/pre>\n

\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8(Web\u30b5\u30fc\u30d0)\u306e\u30da\u30fc\u30b8\u5358\u4f4d\u3067\u5fdc\u7b54\u6642\u9593(\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6\u30fb\u8868\u793a\u30b9\u30d4\u30fc\u30c9)\u3092\u6e2c\u5b9a\u3059\u308b\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8(\u30d0\u30c3\u30c1\u51e6\u7406\u30d7\u30ed\u30b0\u30e9\u30e0)\u306e\u5b9f\u884c\u4f8b<\/h3>\n
\r\n[mag4j@localhost ~]# chmod 755 website_response_time.sh\r\n[mag4j@localhost ~]# .\/website_response_time.sh get https:\/\/www.google.com\r\n{"site": "https:\/\/www.google.com", "method": "GET", "http_status": "200", "response_time": "0.130"}\r\n[mag4j@localhost ~]# .\/website_response_time.sh post https:\/\/your_api_server.com\r\n{"site": "https:\/\/your_api_server.com", "method": "POST", "http_status": "200", "response_time": "0.300"}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u3092\u59cb\u3081\u3068\u3059\u308b\u30b9\u30de\u30fc\u30c8\u30c7\u30d0\u30a4\u30b9\u306e\u666e\u53ca\u3084\u30e2\u30ce\u3092\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3067\u7e4b\u3050IoT\u306e\u958b\u767a\u304c\u6d3b\u767a\u5316\u3057\u3066\u304d\u305f\u6700\u8fd1\u3067\u306f\u3001\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u30bf\u30a4\u30e0\u30fb\u30ec\u30b9\u30dd\u30f3\u30b9\u901f\u5ea6\u306f\u3055\u3089\u306b\u91cd\u8981\u306a\u8981\u7d20\u3068\u306a\u3063\u3066\u304d\u307e\u3057\u305f\u3002 \u4e00\u822c\u7684\u306aGET\u30e1\u30bd\u30c3\u30c9 […]<\/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,31,79,82],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5235"}],"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=5235"}],"version-history":[{"count":2,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5235\/revisions"}],"predecessor-version":[{"id":5246,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/5235\/revisions\/5246"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=5235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=5235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=5235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}