FREECPU=`iostat | head -4 | tail -1 | cut -d' ' -f31`
USEDCPU=`echo 100 - ${FREECPU}|bc`
echo "FREECPU: ${FREECPU} USEDCPU: ${USEDCPU} "
TOTALMEM=`free -m | grep "Mem:" | cut -d' ' -f12`
USEDMEM=`free -m | grep "Mem:" | cut -d' ' -f20`
FREEMEM=`free -m | grep "Mem:" | cut -d' ' -f29`
echo "TOTALMEM: ${TOTALMEM} USEDMEM: ${USEDMEM} FREEMEM: ${FREEMEM} "
TOTALSWAP=`free -m | grep "Swap:" | cut -d' ' -f10`
USEDSWAP=`free -m | grep "Swap:" | cut -d' ' -f20`
FREESWAP=`free -m | grep "Swap:" | cut -d' ' -f27`
echo "TOTALSWAP: ${TOTALSWAP} USEDSWAP: ${USEDSWAP} FREESWAP: ${FREESWAP}"
FREECPU=`iostat | head -4 | tail -1 | cut -d' ' -f31`
USEDCPU=`echo 100 - ${FREECPU}|bc`
echo "FREECPU: ${FREECPU} USEDCPU: ${USEDCPU} "
TOTALMEM=`free -m | grep "Mem:" | awk '{print $2}'`
USEDMEM=`free -m | grep "Mem:" | awk '{print $3}'`
FREEMEM=`free -m | grep "Mem:" | awk '{print $4}'`
echo "TOTALMEM: ${TOTALMEM} USEDMEM: ${USEDMEM} FREEMEM: ${FREEMEM} "
TOTALSWAP=`free -m | grep "Swap:" | cut -d' ' -f10`
USEDSWAP=`free -m | grep "Swap:" | cut -d' ' -f20`
FREESWAP=`free -m | grep "Swap:" | cut -d' ' -f27`
echo "TOTALSWAP: ${TOTALSWAP} USEDSWAP: ${USEDSWAP} FREESWAP: ${FREESWAP}"
转载于:https://blog.51cto.com/chenzm/1303128