shell查看CPU 硬盘 内存使用率

[root@tiger ~]# cat 1.sh 
#!/bin/sh
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)}'

[root@tiger ~]# chmod a+x 1.sh

[root@tiger ~]# bash 1.sh 
Memory Usage: 456/7805MB (5.84%)
Disk Usage: 3/17GB (19%)
CPU Load: 0.99

 

你可能感兴趣的:(shell查看CPU 硬盘 内存使用率)