swap bar graph

whytewolf's picture

description: 

this one is really just a stupid bash trick. all it will do is display the current swap usage as a bar graph. and there is more formatting then there is calculation.

One liner: 

x=`cat /proc/swaps | egrep 'partition|file' | awk '{printf ( "scale=3;a=((%s/%s)*10);scale=0;a/1\n", $4, $3)}' | bc`; i=0; j=0; echo -n '|'; while [ $i -lt 100 ]; do while [ $j -lt $x ]; do i=$[$i+1]; j=$[$j+1]; echo -n '='; done; i=$[$i+1]; echo -n ' '; done; echo '|'

Output: 

|================================================================================================    |

Tags: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <p>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.