{"id":2981,"date":"2016-02-24T19:27:16","date_gmt":"2016-02-24T19:27:16","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=2981"},"modified":"2016-02-24T19:27:16","modified_gmt":"2016-02-24T19:27:16","slug":"disk-usage","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2016\/02\/24\/disk-usage\/","title":{"rendered":"Disk Usage"},"content":{"rendered":"<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#!\/bin\/sh\n# set -x\n# Shell script to monitor or watch the disk space\n# It will send an email to $ADMIN, if the (free available) percentage of space is &gt;= 90%.\n# -------------------------------------------------------------------------\n# Set admin email so that you can get email.\nADMIN=&quot;root&quot;\n# set alert level 90% is default\nALERT=90\n# Exclude list of unwanted monitoring, if several partions then use &quot;|&quot; to separate the partitions.\n# An example: EXCLUDE_LIST=&quot;\/dev\/hdd1|\/dev\/hdc5&quot;\nEXCLUDE_LIST=&quot;\/auto\/ripper&quot;\n#\n#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n#\nfunction main_prog() {\nwhile read output;\ndo\n#echo $output\n  usep=$(echo $output | awk &#039;{ print $1}&#039; | cut -d&#039;%&#039; -f1)\n  partition=$(echo $output | awk &#039;{print $2}&#039;)\n  if &#x5B; $usep -ge $ALERT ] ; then\n     echo &quot;Running out of space \\&quot;$partition ($usep%)\\&quot; on server $(hostname), $(date)&quot; | \\\n     mail -s &quot;Alert: Almost out of disk space $usep%&quot; $ADMIN\n  fi\ndone\n}\nif &#x5B; &quot;$EXCLUDE_LIST&quot; != &quot;&quot; ] ; then\n  df -H | grep -vE &quot;^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}&quot; | awk &#039;{print $5 &quot; &quot; $6}&#039; | main_prog\nelse\n  df -H | grep -vE &quot;^Filesystem|tmpfs|cdrom&quot; | awk &#039;{print $5 &quot; &quot; $6}&#039; | main_prog\nfi\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/sh # set -x # Shell script to monitor or watch the disk space # It will send an email to $ADMIN, if the (free available) percentage of space is &gt;= 90%. # &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- # Set admin email so that you can get email. ADMIN=&quot;root&quot; # set alert level 90% is default ALERT=90 # Exclude &#8230; <a title=\"Disk Usage\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2016\/02\/24\/disk-usage\/\" aria-label=\"Read more about Disk Usage\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-2981","post","type-post","status-publish","format-standard","hentry","category-shell-scripts"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2981","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=2981"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/2981\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=2981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=2981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=2981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}