[[email protected] ~]# 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)}‘
[[email protected] ~]# chmod a+x 1.sh
[[email protected] ~]# bash 1.sh
Memory Usage: 456/7805MB (5.84%)
Disk Usage: 3/17GB (19%)
CPU Load: 0.99
原文地址:https://blog.51cto.com/14051712/2416493
时间: 2024-10-13 03:20:58