{"id":1971,"date":"2016-03-30T05:33:28","date_gmt":"2016-03-30T04:33:28","guid":{"rendered":"https:\/\/andyland.info\/wordpress\/?p=1971"},"modified":"2016-02-28T12:00:36","modified_gmt":"2016-02-28T11:00:36","slug":"improving-the-stability-of-the-tcpsclient","status":"publish","type":"post","link":"https:\/\/andyland.info\/wordpress\/improving-the-stability-of-the-tcpsclient\/","title":{"rendered":"Improving the stability of the TCPSClient"},"content":{"rendered":"<p>This script is quite helpful when you want\u00a0to run the <a href=\"http:\/\/techlife.sg\/TCPSClient\/\">TCPSClient<\/a> (beta 3) somewhat completely unattended.<\/p>\n<p>If the program hangs up, fails or anything doesn&#8217;t work as expected the CPU load increased drastically. This is taken as an indicator and the TCPSClient will be terminated and restarted.<\/p>\n<pre>!\/bin\/bash\r\nPROCESSNAME=TCPSClient.bin\r\nCPU_USAGE_THRESHOLD=1010\r\ndeclare -i MULTIPLIER=10\r\n\r\nkillall -v $PROCESSNAME\r\nsleep 3\r\nwhile true; do\r\n\tif ps ax | grep -v grep | grep TCPSClient &gt; \/dev\/null \r\n\tthen\r\n\t\tCPU_TEMP_USAGE=$(top -bn1 |grep TCPSClient | awk -F' ' '{print $9}')\r\n\t\tCPU_USAGE=$(echo \"scale=2;$CPU_TEMP_USAGE*$MULTIPLIER\"|bc)\r\n\t\tCPU_INT=${CPU_USAGE%.*}\r\n\t\tif [ $CPU_INT -gt $CPU_USAGE_THRESHOLD ] ; then\r\n\t\t\techo KILLING\r\n\t\t\tkillall -v $PROCESSNAME\r\n\t\t\tsleep 3\r\n\t\tfi\r\n\telse\r\n\t\t\/home\/pi\/TCPSClient\/TCPSClient.bin &amp;\r\n\t\tsleep 3\r\n\tfi\r\ndone\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>This is one of the very few Linux scripts I did. Be gentle. Feel free to contact me if there are questions, suggestions, etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This script is quite helpful when you want\u00a0to run the TCPSClient (beta 3) somewhat completely unattended. If the program hangs up, fails or anything doesn&#8217;t work as expected the CPU load increased drastically. This is taken as an indicator and the TCPSClient will be terminated and restarted. !\/bin\/bash PROCESSNAME=TCPSClient.bin CPU_USAGE_THRESHOLD=1010 \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/andyland.info\/wordpress\/improving-the-stability-of-the-tcpsclient\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[21],"tags":[58,120,104,123],"class_list":["post-1971","post","type-post","status-publish","format-standard","hentry","category-video","tag-raspberry-pi-2","tag-rpi","tag-syphon","tag-tcpsclient","odd"],"_links":{"self":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/1971","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1971"}],"version-history":[{"count":0,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/1971\/revisions"}],"wp:attachment":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}