title: Consul - Alert if drive is full
body: <p>In the demo of consul, there are checks for disk utilization and memory utilization. <img src="https://i.stack.imgur.com/R1bpc.png" alt="enter image description here"></p>
  
  <p><a href="http://demo.consul.io/ui/#/ams2/nodes/ams2-server-1" rel="nofollow noreferrer">http://demo.consul.io/ui/#/ams2/nodes/ams2-server-1</a></p>
  
  <p>How could you write a configuration to do what the demo shows? Warning at 10% and critical erros at 5% ? </p>
  
  <p>Here is what I am trying</p>
  
  <pre><code>{
    "check": {
       "name": "Disk Util",
       "script": "disk_util=$(df -k | grep '/dev/sda1' | awk '{print $5}' | sed 's/[^0-9]*//g' ) | if [ $disk_util &gt;  90 ] ; then echo 'Disk /dev/sda above 90% full' &amp;&amp; exit 1; elif [ $disk_util &gt; 80 ] ; then echo 'Disk /dev/sda above 80%' &amp;&amp; exit 3;  else exit 0; fi",
       "interval": "2m"
       }
  }
  </code></pre>
  
  <p>Here is the same script, but more human readable</p>
  
  <pre><code>disk_util=$(df -k | grep '/dev/sda1' | awk '{print $5}' | sed 's/[^0-9]*//g' ) | 
  if [ $disk_util &gt;  90 ] 
   then echo 'Disk /dev/sda above 90% full' &amp;&amp; exit 1
  elif [ $disk_util &gt; 80 ] 
   then echo 'Disk /dev/sda above 80%' &amp;&amp; exit 3
  else exit 0; fi
  </code></pre>
  
  <p>It seems like the check is working, but it doesn't print out any text. How can I verify this is working, and print output? </p>
  
  <p><img src="https://i.stack.imgur.com/kT8rm.png" alt="enter image description here"></p>