菜鸟笔记
提升您的技术认知

shell查看cpu 硬盘 内存使用率-ag真人游戏

[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

 

网站地图