{"id":76,"date":"2023-07-20T14:14:55","date_gmt":"2023-07-20T06:14:55","guid":{"rendered":"https:\/\/guoyingxu.cn\/?p=76"},"modified":"2023-07-20T14:14:55","modified_gmt":"2023-07-20T06:14:55","slug":"check_pod-service","status":"publish","type":"post","link":"https:\/\/guoyingxu.cn\/?p=76","title":{"rendered":"check_pod-service"},"content":{"rendered":"\n<!doctype html>\n<html>\n<head>\n<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>\n<title><\/title>\n<\/head>\n<body><h1 id='checkpod-service'>check_pod-service<\/h1>\n<pre><code class='language-shell' lang='shell'>#!\/usr\/bin\/bash\ndingtalk_token=&#39;2fb7e1b45da3f32fea5ffeded1bd3036cd42d574774cbed57bdbfeea7244ad49&#39;\n#\u6b63\u5f0f\u73af\u5883\n#https:\/\/oapi.dingtalk.com\/robot\/send?access_token=747c3ca261a114f98d5ef6589cb92c78422d195f9e83c46303affb1f382ac059\n#kubectl get pod |awk &#39;{if (NR&gt;1){print $1,$2,$3,$4,$5}}&#39;|tee tmp.log\nkubectl get pod --kubeconfig=\/usr\/local\/cm-tools\/secrets\/.kube\/rtm_prod_tcloud.conf |awk &#39;{if (NR&gt;1){print $1,$2,$3,$4,$5}}&#39;|tee tmp.log\nIFS=&#39;\n&#39;\nfor i in `cat tmp.log`\ndo\n        POD_NAME=`echo &quot;$i&quot;|awk &#39;{print $1}&#39;`\n        POD_READY=`echo &quot;$i&quot;|awk &#39;{print $2}&#39;`\n        POD_STATUS=`echo &quot;$i&quot;|awk &#39;{print $3}&#39;`\n        POD_RESTARTS=`echo &quot;$i&quot;|awk &#39;{print $4}&#39;`\n        POD_AGE=`echo &quot;$i&quot;|awk &#39;{print $5}&#39;`\n#       echo $POD_NAME $POD_READY $POD_STATUS $POD_RESTARTS $POD_AGE\n#\u6709\u4e09\u4e2a\u670d\u52a1\u72b6\u6001\u4e0d\u5bf9\uff0c\u76ee\u524d\u5148\u6392\u9664\u4e86\u3002\n        if [ $POD_NAME = &quot;faw-statistics-report-674998fc66-kghhh&quot; -o $POD_NAME = &quot;faw-statistics-report-674998fc66-pgh5p&quot; -o $POD_NAME = &quot;faw-statistics-report-674998fc66-pl8jq&quot; ];then\n                continue;\n        fi\n        if [ $POD_STATUS != &quot;Running&quot; ];then\n                echo $POD_NAME $POD_READY $POD_STATUS $POD_POD_RESTARTS $POD_AGE\n                cont=&#39;[\u5fae\u7b11]\u76d1\u63a7\u544a\u8b66-POD\\n\u5fae\u670d\u52a1\uff08&#39;$POD_NAME&#39;\uff09\u72b6\u6001\u4e3a\uff08&#39;$POD_STATUS&#39;\uff09\u4e0d\u6b63\u5e38\uff0c\u8bf7\u53ca\u65f6\u5904\u7406\u3002\\n&#39;$POD_NAME&#39;\\t&#39;$POD_READY&#39;\\t&#39;$POD_STATUS&#39;\\t&#39;$POD_RESTARTS&#39;\\t&#39;$POD_AGE&#39;&#39;\n        curl &#39;https:\/\/oapi.dingtalk.com\/robot\/send?access_token=&#39;${dingtalk_token} -H &#39;Content-Type: application\/json&#39; -d &#39; {&quot;msgtype&quot;: &quot;text&quot;, &quot;text&quot;: {&quot;content&quot;: &quot;&#39;&quot;${cont}&quot;&#39;&quot;}}&#39;\n        fi\n\ndone\nexit\n<\/code><\/pre>\n<pre><code>#!\/usr\/bin\/bash\ndingtalk_token=&#39;2fb7e1b45da3f32fea5ffeded1bd3036cd42d574774cbed57bdbfeea7244ad49&#39;\n#\u6b63\u5f0f\u73af\u5883\n#https:\/\/oapi.dingtalk.com\/robot\/send?access_token=747c3ca261a114f98d5ef6589cb92c78422d195f9e83c46303affb1f382ac059\n#kubectl get pod |awk &#39;{if (NR&gt;1){print $1,$2,$3,$4,$5}}&#39;|tee tmp.log\nkubectl get pod --kubeconfig=\/usr\/local\/cm-tools\/secrets\/.kube\/rtm_prod_tcloud.conf |awk &#39;{if (NR&gt;1){print $1,$2,$3,$4,$5}}&#39;|tee tmp.log\nIFS=&#39;\n&#39;\nfor i in `cat tmp.log`\ndo\n        POD_NAME=`echo &quot;$i&quot;|awk &#39;{print $1}&#39;`\n        POD_READY=`echo &quot;$i&quot;|awk &#39;{print $2}&#39;`\n        POD_STATUS=`echo &quot;$i&quot;|awk &#39;{print $3}&#39;`\n        POD_RESTARTS=`echo &quot;$i&quot;|awk &#39;{print $4}&#39;`\n        POD_AGE=`echo &quot;$i&quot;|awk &#39;{print $5}&#39;`\n#       echo $POD_NAME $POD_READY $POD_STATUS $POD_RESTARTS $POD_AGE\n#\u6709\u4e09\u4e2a\u670d\u52a1\u72b6\u6001\u4e0d\u5bf9\uff0c\u76ee\u524d\u5148\u6392\u9664\u4e86\u3002\n        if [ $POD_NAME = &quot;faw-statistics-report-674998fc66-kghhh&quot; -o $POD_NAME = &quot;faw-statistics-report-674998fc66-pgh5p&quot; -o $POD_NAME = &quot;faw-statistics-report-674998fc66-pl8jq&quot; ];then\n                continue;\n        fi\n        if [ $POD_STATUS != &quot;Running&quot; ];then\n                echo $POD_NAME $POD_READY $POD_STATUS $POD_POD_RESTARTS $POD_AGE\n                cont=&#39;[\u5fae\u7b11]\u76d1\u63a7\u544a\u8b66-POD\\n\u5fae\u670d\u52a1\uff08&#39;$POD_NAME&#39;\uff09\u72b6\u6001\u4e3a\uff08&#39;$POD_STATUS&#39;\uff09\u4e0d\u6b63\u5e38\uff0c\u8bf7\u53ca\u65f6\u5904\u7406\u3002\\n&#39;$POD_NAME&#39;\\t&#39;$POD_READY&#39;\\t&#39;$POD_STATUS&#39;\\t&#39;$POD_RESTARTS&#39;\\t&#39;$POD_AGE&#39;&#39;\n        curl &#39;https:\/\/oapi.dingtalk.com\/robot\/send?access_token=&#39;${dingtalk_token} -H &#39;Content-Type: application\/json&#39; -d &#39; {&quot;msgtype&quot;: &quot;text&quot;, &quot;text&quot;: {&quot;content&quot;: &quot;&#39;&quot;${cont}&quot;&#39;&quot;}}&#39;\n        fi\n\ndone\nexit\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>check_pod-service #!\/usr\/bin\/bash dingtalk_token=&#39;2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-76","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=76"}],"version-history":[{"count":0,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoyingxu.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}