Bash commands to see server stats

I found this little snippet elsewhere and find it very usefull to use in my own scripts for statistiscs:

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)}'

It returns something like:

Memory Usage: 2340/24000MB (9.75%)
Disk Usage: 40/100GB (40%)
CPU Load: 0.04

Published by

Maarten Keizer

Hosting guru. WordPress addict. n00b programmer.

Leave a Reply

Your email address will not be published. Required fields are marked *