Last active
October 26, 2016 08:48
-
-
Save piaoger/2d8954f7bed14b2f1c29920950210f1b to your computer and use it in GitHub Desktop.
query cpu/ram/hdd usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# from http://unix.stackexchange.com/questions/69167/bash-script-that-print-cpu-usage-diskusage-ram-usage | |
FREE_DATA=`free -m | grep Mem` | |
CURRENT=`echo $FREE_DATA | cut -f3 -d' '` | |
TOTAL=`echo $FREE_DATA | cut -f2 -d' '` | |
echo CPU: `top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}'`% | |
echo RAM: $(echo "scale = 2; $CURRENT/$TOTAL*100" | bc)% | |
echo HDD: `df -lh | awk '{if ($6 == "/") { print $5 }}' | head -1 | cut -d'%' -f1`% | |
# list all disks | |
echo HDD: `lsblk | grep disk` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment