shell分析swap分区被哪些程序占用(stress模拟环境)
5、使用脚本分析下#!/bin/bash
#--------------------------------------------------
#Created:2015-05-20
#Author:jimmygong
#Mail:jimmygong@taomee.com
#Function:
#Version:1.0
#--------------------------------------------------
function swapoccupancy ()
{
echo -e "Pid\tSwap\tProgame"
num=0
for pid in `ls -1 /proc|egrep "^"`
do
if [[ $pid -lt 20 ]]
then
continue
fi
program=`ps -eo pid,command|grep -w $pid|grep -v grep|awk '{print $2}'`
for swap in `grep Swap /proc/$pid/smaps 2>/dev/null|awk '{print $2}'`
do
let num=$num+$swap
done
echo -e "${pid}\t${num}\t${program}"
num=0
done|sort -nrk2|head
}
swapoccupancy
exit 0
6、我这边脚本写的是取占用前10的
页:
[1]