{"id":6583,"date":"2014-04-20T13:42:39","date_gmt":"2014-04-20T13:42:39","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/logging-when-limit-exceeds-collection-of-common-programming-errors\/"},"modified":"2014-04-20T13:42:39","modified_gmt":"2014-04-20T13:42:39","slug":"logging-when-limit-exceeds-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/logging-when-limit-exceeds-collection-of-common-programming-errors\/","title":{"rendered":"Logging when limit Exceeds-Collection of common programming errors"},"content":{"rendered":"<p>if your issue is about memory allocation failed you could also use this script to monitor percentage of free memory left<\/p>\n<pre><code>#!\/bin\/bash\n# you can adjust 0.20 meaning 20% to percentage of memory free you want \noutput=$(free | grep \"Swap\" | awk '{if (($4\/$2) &lt; 0.20) print \"memory low\"}')\nif [[ \"$output\" != \"\" ]]; then\n    echo \"...\" | mail -s \"Memory low on \" \nfi\n<\/code><\/pre>\n<p>save it to script file (ex. memmon.sh) and add to crontab it will send email and write log file when detect free memory low as conditioned)<\/p>\n<pre><code># Ex. monitor every 3 min.\n*\/3 * * * * \/home\/user\/memmon.sh &gt;&gt; \/home\/user\/memmon.log\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>if your issue is about memory allocation failed you could also use this script to monitor percentage of free memory left #!\/bin\/bash # you can adjust 0.20 meaning 20% to percentage of memory free you want output=$(free | grep &#8220;Swap&#8221; | awk &#8216;{if (($4\/$2) &lt; 0.20) print &#8220;memory low&#8221;}&#8217;) if [[ &#8220;$output&#8221; != &#8220;&#8221; ]]; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6583","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6583"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6583\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}