- 论坛徽章:
- 0
|
- #!/bin/bash
- LINE_NUM=$(cat /proc/slabinfo | wc -l)
- echo $LINE_NUM
- for (( i=3; i<=${LINE_NUM}; i++ ))
- do
- ACTIVE_OBJ=$(awk '{ print NR, $2}' /proc/slabinfo | awk '{ if ($1 == $i) print $2}')
- echo $ACTIVE_OBJ
- ALL_OBJ=$(awk '{print $3}' /proc/slabinfo | awk 'NR==$i')
- echo `awk '{print $3}' /proc/slabinfo | awk 'NR==i'`
- # echo $ALL_OBJ
- OBJ_SIZE=$(awk '{print $4}' /proc/slabinfo | awk 'NR==$i')
- # echo $OBJ_SIZE
- INACTIVE_OBJ=$((ALL_OBJ-ACTIVE_OBJ))
- # echo $INACTIVE_OBJ
- USED_MEM=$((ACTIVE_OBJ*OBJ_SIZE))
- # echo USED_MEM
- UNUSED_MEM=$((INACTIVE_OBJ*OBJ_SIZE))
- # echo UNUSED_MEM
- TOTAL_USED=$((${TOTAL_USED} + ${USED_MEM}))
- # echo ${TOTAL_USED}
- TOTAL_UNUSED=$((${TOTAL_UNUSED} + ${UNUSED_MEM}))
- done
- FRAG_RATE=$((TOTAL_UNUSED / TOTAL_USED * 100))
- #echo ${FRAG_RATE}
复制代码- ACTIVE_OBJ=$(awk '{ print NR, $2}' /proc/slabinfo | awk '{ if ($1 == $i) print $2}')
复制代码 变量$i传递有问题吗? 为何ACTIVE_OBJ无法正确返回值呢 |
|