{"id":783,"date":"2004-09-16T23:59:00","date_gmt":"2004-09-16T14:59:00","guid":{"rendered":"\/?p=783"},"modified":"2004-09-16T23:59:00","modified_gmt":"2004-09-16T14:59:00","slug":"is-server-alive","status":"publish","type":"post","link":"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/783.html","title":{"rendered":"Is server alive?"},"content":{"rendered":"<p>\u30b5\u30fc\u30d0\u304c\u7a3c\u52d5\u3057\u3066\u3044\u308b\u304b\u3001Web\u30b5\u30fc\u30d0\u304c\u7a3c\u52d5\u3057\u3066\u3044\u308b\u304b\u3001\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002ping, wget, mail\u30b3\u30de\u30f3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u52d5\u4f5c\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u306a\u3089\u30e1\u30fc\u30eb\u3067\u901a\u77e5\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u843d\u3061\u3066\u3044\u308b\u9593\u4e2d\u30e1\u30fc\u30eb\u3092\u4f55\u5ea6\u3082\u9001\u4fe1\u3057\u3066\u304f\u308b\u306e\u306f\u52d8\u5f01\u3057\u3066\u3082\u3089\u3044\u305f\u3044\u306e\u3067\u3001\u30d5\u30e9\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u7528\u610f\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002\u3082\u3063\u3068\u3044\u3044\u65b9\u6cd5\u304c\u3042\u308b\u306a\u3089\u66f8\u304d\u5909\u3048\u305f\u3044\u3068\u3053\u308d\u3060\u3002\u5f8c\u306e\u554f\u984c\u306f\u3069\u3053\u3067\u52d5\u304b\u3057\u3066\u304a\u304f\u304b\u3060\u306a\u3041\u3002<br \/>\n<!--more--><\/p>\n<div class=\"code\">#!\/bin\/sh<br \/>\n# Is server alive ?<br \/>\n#<br \/>\nmailaddress=name@example.com<br \/>\nip=$1<br \/>\nif LANG=C ping -c 1 $ip | grep &#8216;0 received&#8217; &gt; \/dev\/null; then<br \/>\n  echo &#8220;$ip is not alive.&#8221;;<br \/>\n  if [ -f $ip.alive ]; then<br \/>\n    echo $ip | mail -s &#8220;$ip is not alive.&#8221; $mailaddress<br \/>\n    rm $ip.alive<br \/>\n  fi<br \/>\nelse<br \/>\n  if [ -f $ip.alive ]; then<br \/>\n    echo &#8220;$ip is alive.&#8221;;<br \/>\n  else<br \/>\n    echo $ip &gt; $ip.alive<br \/>\n  fi<br \/>\nfi<\/p>\n<p>retval=`LANG=C wget &#8211;spider http:\/\/$ip 2&gt;&amp;1 tee | grep &#8216;200 OK&#8217;`<br \/>\nif [ ! -z &#8220;$retval&#8221; ]; then<br \/>\n#if LANG=C wget &#8211;spider http:\/\/$ip 2>&#038;1 grep &#8216;200 OK&#8217; &gt; \/dev\/null; then<br \/>\n    if [ -f $ip.web.alive ]; then<br \/>\n      echo &#8220;$ip&#8217;s web service is alive.&#8221;;<br \/>\n    else<br \/>\n      echo $ip &gt; $ip.web.alive<br \/>\n    fi<br \/>\nelse<br \/>\n    echo &#8220;$ip&#8217;s web service is not alive.&#8221;;<br \/>\n    if [ -f $ip.web.alive ]; then<br \/>\n      echo $ip | mail -s &#8220;$ip&#8217;s web service is not alive.&#8221; $mailaddress<br \/>\n      rm $ip.web.alive<br \/>\n    fi<br \/>\nfi<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u30b5\u30fc\u30d0\u304c\u7a3c\u52d5\u3057\u3066\u3044\u308b\u304b\u3001Web\u30b5\u30fc\u30d0\u304c\u7a3c\u52d5\u3057\u3066\u3044\u308b\u304b\u3001\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3002ping, wget, mail\u30b3\u30de\u30f3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u52d5\u4f5c\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u306a\u3089\u30e1\u30fc\u30eb\u3067\u901a\u77e5\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u308b\u3002 \u3057\u304b\u3057\u3001\u843d\u3061\u3066\u3044\u308b\u9593\u4e2d\u30e1\u30fc\u30eb &hellip; <a href=\"https:\/\/www.hiro345.net\/blogs\/hiro345\/archives\/783.html\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-783","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/comments?post=783"}],"version-history":[{"count":0,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/posts\/783\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/media?parent=783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/categories?post=783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiro345.net\/blogs\/hiro345\/wp-json\/wp\/v2\/tags?post=783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}