Does what it says on the tin.

swap=`free | tail -1`
total=`echo $swap | awk '{print $2}'`
used=`echo $swap | awk '{print $3}'`
used2=$(echo "scale=2;${used}/${total}"|bc -l)
used_perc=$(echo "scale=2;${used2}*100"|bc -l)

echo "Swap used (%) = $used_perc"

About troyski

I'm a freelance UNIX engineer working in the UK. I'm married to Tina and between us we have six children. I'm a bit of an Apple fan boy, and all the Windows machines in the house are a thing of the past now.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post navigation