{"id":2726,"date":"2012-03-14T19:45:13","date_gmt":"2012-03-14T11:45:13","guid":{"rendered":"http:\/\/jpuyy.com\/?p=2726"},"modified":"2015-04-28T21:01:08","modified_gmt":"2015-04-28T13:01:08","slug":"use-ping-test-network-status","status":"publish","type":"post","link":"https:\/\/jpuyy.com\/?p=2726","title":{"rendered":"shell\u4e0b\u901a\u8fc7ping\u5224\u65ad\u7f51\u7edc\u662f\u5426\u65ad\u5f00"},"content":{"rendered":"<p>&nbsp;<\/p>\n<pre>#!\/bin\/bash\r\n#for use:\r\n#author: jpuyy.com@gmail.com\r\n#modified by xx at date\r\n#version:\r\n#history:\r\n#relate on:\r\nPATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin:~\/bin\r\nexport PATH\r\nnetstat=$(ping -c3 g.cn|grep transmitted |awk '{print $4}')\r\nif((netstat==0))\r\n#time out\r\nthen\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 date &gt;&gt; network.down.log\r\nelse\r\n#ok\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo \"network is ok\"\r\nfi<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>ping \u547d\u4ee4\u5b66\u4e60<\/p>\n<p>ping \u9ed8\u8ba4\u662f\u6bcf\u79d2\u949f\u4e00\u6b21\uff0c\u5982\u679c\u9700\u8981\u66f4\u6539\u65f6\u95f4\uff0c\u53ef\u4ee5 -i interval\uff0c \u53ea\u6709 root \u53ef\u4ee5\u5199\u5c0f\u4e8e 0.2 \u79d2\u7684\u65f6\u95f4\u3002<\/p>\n<pre>ping -i 5 223.5.5.5\r\nping -i 0.1 223.5.5.5<\/pre>\n<p>ping \u672c\u5730\u56de\u73af\u5730\u5740\u6709\u4e09\u79cd\u65b9\u5f0f<\/p>\n<pre>ping 0\r\nping localhost\r\nping 127.0.0.1<\/pre>\n<p>ping \u5177\u4f53\u6b21\u6570\u7ed3\u675f\uff0c\u5982 100 \u6b21<\/p>\n<pre>ping -c 100 jpuyy.com<\/pre>\n<p>\u4f7f\u7528 flood \u65b9\u5f0f ping<\/p>\n<pre>ping -f 0<\/pre>\n<p>\u53ea\u663e\u793a ping \u7684\u7ed3\u679c<\/p>\n<pre>ping -c 5 -q 127.0.0.1<\/pre>\n<p>\u8bbe\u7f6e\u53d1\u9001\u7684 ping \u5305\u5927\u5c0f -s \u5355\u4f4d\u662f bytes\uff0c ping \u81ea\u5e26\u7684 header \u5934\u5927\u5c0f 28 bytes<\/p>\n<pre>ping -s 1000 jpuyy.com<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; #!\/bin\/bash #for use: #author: jpuyy.com@gmail.com #modified by xx at date #version: #history: #relate on: PATH=\/bin:\/sbin:\/usr\/bin:\/usr\/sbin:\/usr\/local\/bin:\/usr\/local\/sbin:~\/bin export PATH netstat=$(ping -c3 g.cn|grep transmitted |awk &#8216;{print $4}&#8217;) if((netstat==0)) #time out then \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 date &gt;&gt; network.down.log else #ok \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 echo &#8220;network is ok&#8221; fi &nbsp; &nbsp; ping \u547d\u4ee4\u5b66\u4e60 ping \u9ed8\u8ba4\u662f\u6bcf\u79d2\u949f\u4e00\u6b21\uff0c\u5982\u679c\u9700\u8981\u66f4\u6539\u65f6\u95f4\uff0c\u53ef\u4ee5 -i interval\uff0c \u53ea\u6709 root \u53ef\u4ee5\u5199\u5c0f\u4e8e 0.2 \u79d2\u7684\u65f6\u95f4\u3002 ping [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-2726","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2726"}],"version-history":[{"count":7,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2726\/revisions"}],"predecessor-version":[{"id":7305,"href":"https:\/\/jpuyy.com\/index.php?rest_route=\/wp\/v2\/posts\/2726\/revisions\/7305"}],"wp:attachment":[{"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpuyy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}