{"id":705,"date":"2017-03-21T20:05:38","date_gmt":"2017-03-21T18:05:38","guid":{"rendered":"https:\/\/helia.ee\/koolitus\/?page_id=705"},"modified":"2017-03-21T20:07:54","modified_gmt":"2017-03-21T18:07:54","slug":"script-millega-monitoorida-ketta-mahu-taituvust","status":"publish","type":"page","link":"https:\/\/helia.ee\/koolitus\/?page_id=705","title":{"rendered":"Script millega monitoorida ketta mahu t\u00e4ituvust"},"content":{"rendered":"<p><strong>Example:<\/strong><\/p>\n<p>You would like to receive an email alert when your disk space gets low. For this, perform a quick Google search for, say, &#8220;Send an Email Alert When Your Disk Space Gets Low&#8221;. Amongst the various result, you will see the one from Linux Jornal. Click the <a href=\"http:\/\/www.linuxjournal.com\/content\/tech-tip-send-email-alert-when-your-disk-space-gets-low\">URL<\/a> and you will see the bash script documented on the page.<\/p>\n<p><strong>Create a new text file using <code>nano<\/code> for the bash script:<\/strong><\/p>\n<pre class=\"code-pre \"><code>$ nano monitor_disk_space.sh\r\n<\/code><\/pre>\n<p><strong>Copy and paste the contents from the URL:<\/strong><\/p>\n<pre class=\"code-pre \"><code>#!\/bin\/bash\r\nCURRENT=$(df \/ | grep \/ | awk '{ print $5}' | sed 's\/%\/\/g')\r\nTHRESHOLD=90\r\n\r\nif [ \"$CURRENT\" -gt \"$THRESHOLD\" ] ; then\r\n    mail -s 'Disk Space Alert' mailid@domainname.com &lt;&lt; EOF\r\nYour root partition remaining free space is critically low. Used: $CURRENT%\r\nEOF\r\nfi\r\n<\/code><\/pre>\n<p><strong>Note:<\/strong> Please do not forget to replace <code>mailid@domainname.com<\/code> with your e-mail address. Also, please remember that you can modify the subject line as well.<\/p>\n<p>Press &#8220;CTRL+X&#8221; and confirm with &#8220;Y&#8221; in order to save and exit the file.<\/p>\n<p>You have now created a small bash program called <code>monitor_disk_space.sh<\/code> which you can name it as you like.<\/p>\n<p>We need to continue with telling our operating system that this file is an executable.<\/p>\n<p><strong>Give the file <em>executable<\/em> permission using &#8220;chmod&#8221;:<\/strong><\/p>\n<pre class=\"code-pre \"><code>$ chmod +x monitor_disk_space.sh\r\n<\/code><\/pre>\n<p>You can try to run the file by executing it: <code>.\/monitor_disk_space.sh<\/code><\/p>\n<p>Given that we would like this small program to act like a system monitor, we will need to use the utility tool <strong>cron<\/strong> to schedule it to run at certain intervals.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Example: You would like to receive an email alert when your disk space gets low. For this, perform a quick Google search for, say, &#8220;Send an Email Alert When Your Disk Space Gets Low&#8221;. Amongst the various result, you will see the one from Linux Jornal. Click the URL and you will see the bash [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":707,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-705","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=705"}],"version-history":[{"count":1,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/705\/revisions"}],"predecessor-version":[{"id":706,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/705\/revisions\/706"}],"up":[{"embeddable":true,"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=\/wp\/v2\/pages\/707"}],"wp:attachment":[{"href":"https:\/\/helia.ee\/koolitus\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}