Friday, April 8, 2011

Checking memory usage in HP-UX

If you feel that your server is slower than usual, you could check memory usage and swapping with ps, top, vmstat and glance. In this example, as you can see in Mem Util and Swap Util in glance this server used a lot of memory and swap space at some time, but at the time of this sample there were no paging or memory shortage as seen in memory "active" (in parentheses) in the top report, as seen in low values in Page In and Page Out in glance, and also low values in pi and po in vmstat report.

$ ps -elx|sort -k 10b,10rn|more
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME COMD
1401 S 113 6938 1 0 154 20 e000000163528680 9728 e000000149c7d080 ? 465:09 ora_s000_mydb
1401 S 113 6083 1 0 154 20 e0000001bcc40400 9620 e0000001674f6ee8 ? 0:00 oraclemydb (LOCAL=NO)
1401 S 113 6940 1 0 154 20 e0000001635c5100 9147 e000000149c7d080 ? 3:13 ora_d000_mydb
1401 S 113 6932 1 0 156 20 e0000001636fc700 9103 e000000167e27128 ? 2:40 ora_smon_mydb
1401 S 113 6926 1 0 156 20 e000000163664980 9012 e000000167e270f8 ? 25:24 ora_dbw0_mydb
1401 S 113 6934 1 0 156 20 e00000016362a700 8992 e000000167e27138 ? 0:02 ora_reco_mydb
1401 S 113 6924 1 0 154 20 e00000016340b700 8979 e000000149c7d080 ? 9:48 ora_pmon_mydb
1401 S 113 6936 1 0 156 20 e00000016348ba00 8967 e000000167e27148 ? 12:17 ora_cjq0_mydb
1401 S 113 6930 1 0 156 20 e000000163370980 8938 e000000167e27118 ? 12:59 ora_ckpt_mydb
1401 S 113 6928 1 0 156 20 e0000001634d6980 8924 e000000167e27108 ? 9:48 ora_lgwr_mydb
2541 R 0 6003 1 0 -16 10 e0000001a7370d00 4271 - ? 0:22 /opt/perf/bin/midaemon
2401 S 113 5999 5798 0 154 10 e0000001bb0fba00 1016 e00000018409c800 pts/0 0:19 glance
541 R 0 1 0 0 152 20 e00000010853e380 574 - ? 0:10 init
1401 S 113 6961 1 0 154 20 e000000163945a00 552 e000000149c7d080 ? 1:02 /oracle92/product/9.2.0/bin/tnslsnr LISTENER -inherit
1401 S 0 6088 1564 0 154 20 e0000001b1098980 491 e00000030f73fe68 ? 0:00 sshd: oracle [priv]
3401 S 113 6090 6088 0 154 20 e0000001b2c90100 491 e000000149c7d080 ? 0:00 sshd: oracle@pts/1
3401 S 127 6333 6331 0 154 20 e0000001c2b09d00 487 e000000149c7d080 ? 0:00 sshd: myuser@pts/2
1401 S 0 6331 1564 0 154 20 e0000001c8a15d00 471 e00000014eeffee8 ? 0:00 sshd: myuser [priv]
1401 S 0 6605 1564 0 154 20 e0000001ac0fc980 471 e000000164a63568 ? 0:00 sshd: otherusr [priv]
3401 S 12 6617 6605 0 154 20 e0000001b550c680 471 e000000149c7d080 ? 0:00 sshd: otherusr@pts/3
3401 S 113 5794 5791 0 154 20 e0000001b8695380 466 e000000149c7d080 ? 0:00 sshd: oracle@pts/0
$ top

System: myserver Fri Apr 8 10:37:43 2011
Load averages: 0.02, 0.12, 0.34
182 processes: 141 sleeping, 41 running
Cpu states:
CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS
0 0.02 0.2% 0.0% 0.2% 99.6% 0.0% 0.0% 0.0% 0.0%
--- ---- ----- ----- ----- ----- ----- ----- ----- -----
avg 0.02 0.2% 0.0% 0.2% 99.6% 0.0% 0.0% 0.0% 0.0%

System Page Size: 4Kbytes
Memory: 1151700K (788492K) real, 3840196K (2936972K) virtual, 26556K free Page# 1/14

CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
0 ? 27479 root 152 20 264M 20128K run 95:34 0.34 0.34 agctrlcell
0 ? 6938 oracle 154 20 1973M 4444K sleep 465:16 0.32 0.31 ora_s000_mydb
0 ? 2731 root 152 20 155M 7928K run 4:22 0.31 0.31 vxpal
0 ? 75 root 152 20 17208K 15296K run 44:50 0.29 0.29 vxfsd
0 ? 2666 root 152 20 112M 4332K run 1:30 0.29 0.29 vxsvc
0 ? 27475 root 152 20 694M 15332K run 84:10 0.29 0.29 evtcell
0 ? 3532 root 168 20 11700K 592K sleep 307:47 0.29 0.29 utild
0 ? 2357 root 152 20 26072K 1880K run 0:29 0.14 0.14 rpcd
0 ? 3021 root 152 20 92272K 2296K run 0:09 0.14 0.14 vxpal
0 ? 3078 root 152 20 99636K 1568K run 0:08 0.14 0.14 vxpal
0 ? 3197 root 152 20 25832K 1612K run 0:54 0.14 0.14 swagentd
$ glance

C - cum/interval toggle Page 1 of 2
ProcList CPU Rpt Mem Rpt Disk Rpt NextKeys SlctProc Help Exit
Glance C.04.70.001 10:31:24 myserver ia64 Current Avg High
------------------------------------------------------------------------------------------------------------------------------------------------------
CPU Util SSU U | 5% 32% 86%
Disk Util F | 1% 30% 77%
Mem Util S SU U | 99% 100% 100%
Swap Util U UR R | 26% 26% 26%
------------------------------------------------------------------------------------------------------------------------------------------------------
MEMORY REPORT Users= 4
Event Current Cumulative Current Rate Cum Rate High Rate
--------------------------------------------------------------------------------
Page Faults 0 7593 0.0 12.5 548.6
Page In 0 5149 0.0 8.4 350.8
Page Out 0 56 0.0 0.0 1.3
KB Paged In 0kb 20.1mb 0.0 33.9 7455.2
KB Paged Out 0kb 224kb 0.0 0.3 5.4
Reactivations 0 0 0.0 0.0 0.0
Deactivations 0 0 0.0 0.0 0.0
KB Deactivated 0kb 0kb 0.0 0.0 0.0
VM Reads 0 435 0.0 0.7 33.1
VM Writes 0 0 0.0 0.0 0.0
Total VM : 3.6gb Sys Mem : 2.6gb User Mem: 924mb Phys Mem : 3.7gb
Active VM: 2.3gb Buf Cache: 1mb Free Mem: 25mb FileCache: 215mb
MemFS Blk Cnt: 0 MemFS Swp Cnt: 0

ProcList CPU Rpt Mem Rpt Disk Rpt NextKeys SlctProc Help Exit
$ vmstat 10
procs memory page faults cpu
r b w avm free re at pi po fr de sr in sy cs us sy id
3 1 0 667747 14981 1 0 7 10 1 0 34 297 2178 238 3 1 96
1 1 0 562145 14956 4 0 12 0 0 0 0 221 644 139 1 1 98
1 1 0 762287 14964 0 0 0 0 0 0 0 133 545 97 1 0 98
1 1 0 761304 14980 0 0 0 0 0 0 0 118 451 87 0 0 100
1 1 0 550784 14964 0 0 0 0 0 0 0 118 387 88 0 0 100

Also, if you have root access you can check memory usage with swapinfo, sam and in /dev/mem like this (example from a different server):

# swapinfo -tm
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 8192 490 3606 6% 0 - 1 /dev/vg00/lvol2
reserve - 2986 -2986
memory 3016 2780 236 92%
total 11208 6256 856 56% - 0 -
# echo phys_mem_pages/D | adb -k /stand/vmunix /dev/mem
phys_mem_pages:
phys_mem_pages: 1048064
# sam

┌ System Properties (MYSERVR) ┐
│┌────────────────────────────────────────┐│
││ ^│
││ [ Refresh ] │
││ │
││ ┌─────┐┌────┐┌─────────┐┌─────┐┌────┐ │
││ │ Processor ││ Memory ││ Operating System ││ Network ││ Dynamic │ │
││ ┌───────/ \──────────────────────────┐ │
││ │┌────────────────────────────────────┐│ │
││ ││Physical Memory: 4097.7 MB ││ │
││ ││Real Memory: ││ │
││ ││ Active: 954731.6 KB ││ │
││ ││ Total: 1318838.6 KB ││ │
││ ││Virtual Memory: ││ │
││ ││ Active: 1850220.6 KB ││ │
││ ││ Total: 2375723.8 KB ││ │
││ ││Free Memory Pages: 21640 at 4 KB/page ││ │
││ ││Swap Space: ││ │
││ ││ Avail: 8192 MB ││ │
││ ││ Used: 3461 MB ││v│
│└────────────────────────────────────────┘│
│──────────────────────────────────────────│
│ [ OK ] [ Help ] │
└──────────────────────────────────────────┘

More Information:

Memory Usage (What is using all of the memory?)

No comments:

Post a Comment