#/usr/bin/sh echo '=========== 统计信息 ===========' #获取内存情况 memory=(`free | awk 'NR==2{print $2,$3}'`) memoryAll=${memory[0]} memoryUsed=${memory[1]} echo 内存总计:$memoryAll echo 内存使用:$memoryUsed #cpu负载 cpuLoad=(`cat /proc/loadavg | awk '{print $1,$2,$3,$4}'`) load1=${cpuLoad[0]} load5=${cpuLoad[1]} load15=${cpuLoad[2]} loadProcess=${cpuLoad[3]} echo CPU负载1分钟:$load1 echo CPU负载5分钟:$load5 echo CPU负载15分钟:$load15 echo 活跃进程/总进程:$loadProcess #cpu使用率 cpuUsage=`top -n 1 | awk 'NR==3 {print $2}'` echo CPU使用率:$cpuUsage% #磁盘使用率 disk=(`df | grep /dev/ | awk '{print $2,$3}'`) diskAll=${disk[0]} diskUsed=${disk[1]} echo 磁盘总计:$diskAll echo 磁盘使用:$diskUsed #网络带宽累计值 network=(`cat /proc/net/dev | grep eth0 | awk '{print $2,$10}'`) networkIn=${network[1]} networkOut=${network[1]} echo 网络进累计:$networkIn echo 网络出累计:$networkOut