1837091 Members
2549 Online
110112 Solutions
New Discussion

ps -e -o pmem

 
Dayanand Sharma_1
New Member

ps -e -o pmem

Hi Gurus,

In solaris, ps -e -o pmem shows the ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage. The -o option with HP-UX works after exporting env variable UNIX95=XPG4. but the "pmem" flag doesnt work and says :--

ps: pmem is not a valid field name

Does anyone know the any flag I can use with -o option to get the same output in HP-UX as "pmem" in Sun Solaris ?
I need it to get a perl script going.

Thanks in Advance
-Dayanand
2 REPLIES 2
Steven Sim Kok Leong
Honored Contributor

Re: ps -e -o pmem

Hi,

One workaround on HP-UX is to use the the output of top.

Following lists out 6000 processes (you can use a value that exceeds the total number of processes in your system) and pipes it into the file test without iterating:

# top -n 6000 -f test -d 1

Subsequently, you can use any of the regex tools such as awk or perl to extract the RES portion and compute a percentage over the total amount of physical memory or any other statistics:

# head -20 test
System: hpi2000 Sat Apr 20 06:24:25 2002
Load averages: 0.01, 0.00, 0.00
62 processes: 58 sleeping, 4 running
Cpu states:
LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS
0.01 0.0% 0.0% 0.0% 100.0% 0.0% 0.0% 0.0% 0.0%

Memory: 34912K (20212K) real, 443812K (127300K) virtual, 149400K free Page# 1/1

TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND
? 36 root 152 20 0K 1728K run 2:06 0.33 0.33 vxfsd
? 5724 root 154 20 10872K 1224K sleep 0:00 0.09 0.09 sshd
? 3 root 128 20 0K 64K sleep 6:58 0.06 0.06 statdaemon
? 7284 root 152 20 1812K 6056K run 0:22 0.06 0.06 samd
pts/0 5874 root 178 20 9372K 416K run 0:00 0.19 0.04 top
? 0 root 127 20 0K 80K sleep 0:16 0.02 0.02 swapper
? 1 root 168 20 8956K 296K sleep 0:00 0.02 0.02 init
? 2 root 128 20 0K 64K sleep 0:01 0.02 0.02 vhand
? 4 root 128 20 0K 64K sleep 0:05 0.02 0.02 unhashdaemon
? 8 root 100 20 0K 64K sleep 0:00 0.02 0.02 supsched

Hope this helps. Regards.

Steven Sim Kok Leong
T. M. Louah
Esteemed Contributor

Re: ps -e -o pmem

.: HPUX offers similar flexibility with UNIX95:
HOW TO SET UP UNIX95 # export UNIX95="" or yes
.: To sort all the proceses by memory size:
# UNIX95= ps -eo vsz,ruser,args | sort -rn | more
(Note space usage between command & arguments)
To find all processes that have a specific basename:
UNIX95= ps -fC deamon_name
No grep needed, and most important, it returns ONLY the deamon you are after. Check out the difference between:
# ps -ef | grep sh
# UNIX95= ps -fC sh
The second form (which activates the -C option in XPG4 mode) is really inetresting.
Little learning is dangerous!