简单统计磁盘,cpu,内存使用情况
#!/bin/bash
mem_total=`free -m | grep Mem |awk '{print $2}'`
mem_used=`free -m | grep Mem |awk '{print $3}'`
cpu_idl=`top -b -n 1 | grep Cpu | awk '{print $5}' | cut -f 1 -d "%"`
cpu_used=`echo "scale=2;100-$cpu_idl"|bc`
#disk_total=`fdisk -l | grep "Disk"`
disk_avail=`df -lhP |awk '{print $6": "$4"/"$2}'`
hostname=`hostname`
echo "########################${hostname}############################"
#echo "disk_total is ${disk_total}"
echo "disk_avail is ${disk_avail}"
echo " "
echo "mem_used is ${mem_used}M"
echo "mem_total is ${mem_total}M"
echo " "
echo "cpu_used is ${cpu_used}%"