Thursday, November 12, 2009

Find Swap usage on Solaris

In Solaris, swap and physical memory can be interchanged, that is physical memory can be
reserved for swap instead of using the swap device.

1. swap -lh
2. swap -sh
3. prtconf | grep size
4. ps -A -o vsz,rss | awk 'BEGIN {size = 0; rss = 0;} {size += $1; rss
+= $2} END{printf("Size = %d kb, RSS = %d kb\n", size, rss);}'

The first shows how much of the physical swap device has been used. The
second looks at how much swap is used and reserved, versus available.
The third is just a sanity check for the physical memory. The fourth
looks at all of the processes in the system and allows us to see the
total difference between the vsize and the rss.


Now to figure out per process usage of swap space, we can do the following


1) bash-3.00$ top -b -o size
load averages: 2.99, 2.94, 3.02; up 199+21:07:21 12:06:32
103 processes: 99 sleeping, 4 on cpu
CPU states: 88.7% idle, 9.0% user, 2.3% kernel, 0.0% iowait, 0.0% swap
Memory: 64G phys mem, 4834M free mem, 16G total swap, 16G free swap

PID USERNAME LWP PRI NICE SIZE RES STATE TIME CPU COMMAND
12510 uxbea 57 33 4 2313M 963M sleep 199:53 0.08% java
10790 uxbea 208 59 4 2309M 1258M sleep 33.8H 0.01% java
17942 uxbea 153 22 0 2273M 1098M sleep 27:32 0.04% java
26082 uxbea 130 50 0 1981M 729M sleep 426:29 0.07% java
23365 uxbea 130 59 0 1976M 723M cpu/4 332:06 0.13% java
24662 uxbea 129 56 0 1963M 751M sleep 186:11 0.03% java
9353 uxbea 150 24 4 1778M 1365M sleep 182:53 1.81% java
18747 uxbea 130 1 0 1486M 610M sleep 84.2H 0.03% java
19334 uxbea 130 1 0 1441M 1063M cpu/20 33:17 3.18% java
25622 uxbea 125 53 0 1431M 583M sleep 183:50 0.04% java
7565 uxbea 97 54 0 1274M 673M sleep 38:27 0.02% java
24810 uxbea 285 53 0 1226M 1091M sleep 27.6H 0.09% java
17895 uxbea 230 1 4 1098M 820M sleep 25.0H 0.06% java
10901 uxbea 164 55 4 1066M 693M sleep 21:10 0.03% java
12056 uxbea 227 43 4 1061M 606M sleep 24.4H 0.08% java


looks like pid 12510 is using most virtual memory.. to figure out how much of i
is swap, use pmap's help

2) bash-3.00$ pmap -S 12510 | tail -1
total Kb 2368032 2022672

PID 12510 is using 2.02G of swap.






No comments: