Sunday, December 2, 2012

Memory utilization / usage of java / weblogic processes on RAM for unix / linux

Get the output of below commands

1. cat /proc/meminfo
2. ps -A --sort -rss -o comm,pmem | head -n 11
3. ps -A --sort -rss -o pid,comm,pmem,rss
4. free -m
5. while read command percent rss; do if [[ "${command}" != "COMMAND" ]]; then rss="$(bc <<< "scale=2;${rss}/1024")"; fi; printf "%-26s%-8s%s\n" "${command}" "${percent}" "${rss}"; done < <(ps -A --sort -rss -o comm,pmem,rss | head -n 11)
6. ps -aux

2. COMMAND
ps -A --sort -rss -o comm,pmem | head -n 11

RESULT
COMMAND         %MEM
java            13.4
java            11.8
java            10.7
java             5.8
java             5.1
java             5.0
emagent          0.5
java             0.3
perl             0.0
ntpd             0.0

The java / weblogic processes are using only 52.1% of the total memory

4. COMMAND
free -m

RESULT
             total       used       free     shared    buffers     cached
Mem:         56378      55716        662          0        175       3245
-/+ buffers/cache:      52295       4083
Swap:         4094          0       4094


When you run free command, look for the line which says “-/+ buffers/cache”. This line which shows numbers under used and free, is the RAM you literally have used and literally

have free because of ram allocated to cache and buffers,
this is the line you should refer to when you want to see how much free RAM you have because RAM allocated to buffers and cache will be instantly released and given to a

process whenever it needs it.
So you have 4GB RAM free now.

5. COMMAND
while read command percent rss; do if [[ "${command}" != "COMMAND" ]]; then rss="$(bc <<< "scale=2;${rss}/1024")"; fi; printf "%-26s%-8s%s\n" "${command}" "${percent}" "${rss}"; done < <(ps -A --sort -rss -o comm,pmem,rss | head -n 11)

RESULT
COMMAND                   %MEM    RSS
java                      13.4    7610.14
java                      11.8    6686.60
java                      10.7    6088.11
java                      5.8     3274.82
java                      5.1     2893.45
java                      5.0     2821.26
emagent                   0.5     312.08
java                      0.3     175.11
perl                      0.0     9.97
ntpd                      0.0     4.78

RSS is the portion of memory that a process is using that is held in pysical RAM and is calculated in kb's.

6. COMMAND
ps -aux

RESULT
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2064   620 ?        Ss   Oct20   0:03 init [5]
root         2  0.0  0.0      0     0 ?        S<   Oct20   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   Oct20   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S<   Oct20   0:00 [watchdog/0]

shows you the rss memory as well as the virtual memory of all the pid's, you may then look for your respective pid in the list.
Please note that here the VSZ - virtual size is in kilobytes, RSS - real memory size is in byte units.



Some useful AIX commands:
svmon -Pg -t 1 |grep Pid ; svmon -Pg -t 10 |grep "N"          top 10 processes using the most paging space

svmon -P -O sortseg=pgsp                                               shows paging space usage of processes

ps gv | head -n 1; ps gv | egrep -v "RSS" | sort +6b -7 -n -r 

No comments: