[20140627]linux下显示那个进程使用swap.txt
--要了解linux下那个进程使用交换:
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
for file in /proc/*/status
do
awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file
echo $file
done | sort -k 2 -n -r | less
--最好使用smem命令:
http://pkgs.repoforge.org/smem/
SMEM(8) SMEM(8)
NAME
smem - Report memory usage with shared memory divided proportionally.
SYNOPSIS
smem [options]
DESCRIPTION
smem reports physical memory usage, taking shared memory pages into account. Unshared memory is reported as the
USS (Unique Set Size). Shared memory is divided evenly among the processes sharing that memory. The unshared
memory (USS) plus a process's proportion of shared memory is reported as the PSS (Proportional Set Size). The USS
and PSS only include physical memory usage. They do not include memory that has been swapped out to disk.
Memory can be reported by process, by user, by mapping, or systemwide. Both text mode and graphical output are
available.
# smem -u
User Count Swap USS PSS RSS
rpcuser 1 284 4 35 768
rpc 1 140 112 128 640
ntp 1 300 312 365 1204
root 27 5004 16300 17772 31692
oracle11g 38 0 231468 298472 963372
# smem -w
Area Used Cache Noncache
firmware/hardware 0 0 0
kernel image 0 0 0
kernel dynamic memory 3459608 3311424 148184
userspace memory 315448 134996 180452
free memory 149744 149744 0
--在生产系统测试1下,用户连接多执行有点慢.
# smem -u
User Count Swap USS PSS RSS
stap-server 1 6060 24 31 792
rpcuser 1 228 68 74 752
rpc 1 112 160 171 704
root 24 6928 30296 31497 44136
oracle 2489 808760 12268960 12295238 58056528
# smem -k -t -s swap
# smem -k -t -s swap
PID User Command Swap USS PSS RSS
420 oracle oraclehrp430 (LOCAL=NO) 0 3.7M 3.7M 18.3M
501 oracle oraclehrp430 (LOCAL=NO) 0 3.8M 3.8M 19.2M
527 oracle oraclehrp430 (LOCAL=NO) 0 5.4M 5.4M 24.2M
645 oracle oraclehrp430 (LOCAL=NO) 0 3.7M 3.7M 18.8M
667 oracle oraclehrp430 (LOCAL=NO) 0 4.2M 4.2M 22.0M
813 oracle oraclehrp430 (LOCAL=NO) 0 3.7M 3.7M 18.8M
....
23698 oracle oraclehrp430 (LOCAL=NO) 7.1M 41.1M 41.1M 59.3M
19470 oracle oraclehrp430 (LOCAL=NO) 8.2M 20.2M 20.2M 38.3M
5117 oracle oraclehrp430 (LOCAL=NO) 12.0M 15.5M 15.5M 33.8M
6024 oracle oraclehrp430 (LOCAL=NO) 16.5M 2.5M 2.5M 20.0M
28365 oracle oraclehrp430 (LOCAL=NO) 17.8M 41.5M 41.5M 56.3M
28604 oracle oraclehrp430 (LOCAL=NO) 18.8M 132.0K 141.0K 17.7M
29539 oracle oraclehrp430 (LOCAL=NO) 22.5M 30.7M 30.7M 45.5M
7024 oracle oraclehrp430 (LOCAL=NO) 28.5M 31.8M 31.8M 51.2M
-------------------------------------------------------------------------------
2510 6 787.7M 11.4G 11.4G 55.0G
--慢慢看看man文档.