title: Shell script to display - Memory usage, Disk Usage and CPU Load?
body: <p>I want to diplay the Memory usage, Disk Usage and CPU Load in the following format:</p>
  
  <pre><code>Memory Usage: 33/512MB (6%)    
  Disk usage: 4.2/20GB (23%) 
  CPU Load: 0.01
  </code></pre>
  
  <p>So I started using the below script to do that but somehow it gives me an error</p>
  
  <pre><code>#!/bin/bash
  
  free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%)\n", $3,$2,$3*100/$2 }'
  df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
  top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}' 
  </code></pre>
  
  <p>Below is the error I get -</p>
  
  <pre><code>awk: run time error: not enough arguments passed to printf("Memory Usage: %s/%sMB (%.2f%)
  ")
          FILENAME="-" FNR=2 NR=2
  </code></pre>
  
  <p>I am running ubuntu 12.04. Any idea what's wrong?</p>
  
  <p><strong>Update:-</strong></p>
  
  <p>After running my below shell script -</p>
  
  <pre><code>#!/bin/bash
  
  free -m | awk 'NR==2{printf "Memory Usage: %s/%sMB (%.2f%%)\n", $3,$2,$3*100/$2 }'
  df -h | awk '$NF=="/"{printf "Disk Usage: %d/%dGB (%s)\n", $3,$2,$5}'
  top -bn1 | grep load | awk '{printf "CPU Load: %.2f\n", $(NF-2)}' 
  </code></pre>
  
  <p>I got below output -</p>
  
  <pre><code>Memory Usage: 128504/128896MB (99.70%)
  Disk Usage: 3/48GB (8%)
  CPU Load: 0.40
  </code></pre>
  
  <p>Does CPU Load looks ok? What does 0.40 means? And what number I should say will be high for CPU Load?</p>