11

How to check how much memory a solaris process consumes? I'd like both total address space allocated and the amount that is resident in RAM.

I tried summing pmap output with some awk script, but it was an ugly hack. Is there a better way to script it?

5 Answers5

19
  1. prstat -s rss

    '-s' sorts prstat output by rss column (see man page for other columns). Also try '-a' option for a per user accumulation.

  2. ps -eo pid,pmem,vsz,rss,comm | sort -rnk2 | head

    Top 10 RAM consumers. '-o pmem' displays percentage of resident memory i.e. RAM used by process.

  3. ls -lh /proc/{pid}/as

    Easy way to show total address space (vsz) of a process. Useful in combination with pgrep to accumulate by user, pattern, ... e.g.:

    for pid in `pgrep -U webserver`; do ls -lh /proc/$pid/as; done
    
3

Well, after I've read through some man pages I got the following

ps -o vsz -p $PID | tail -1

It is quite straightforward. The format for resident size is rss.

2

I use variation of this output in scripts:

# prstat -Z 1 1 | tail -3
ZONEID    NPROC  SWAP   RSS MEMORY      TIME  CPU ZONE                        
220       56 1057M  413M   0.3%   1:26:49 0.1% 820f6ce5-7e37-4455-80ab-b28c5de19b43
Total: 56 processes, 169 lwps, load averages: 0.07, 0.06, 0.06
2
prstat

Or maybe a dtrace-script?

pyhimys
  • 1,287
  • 10
  • 10
0

My $.02 as the Zenoss Community Manager...

Zenoss can monitor the health of all your network devices and servers, as well as the processes running on you servers. One of our Community members recently submitted Process Monitoring for Solaris via SNMP: http://community.zenoss.org/docs/DOC-5882

mray
  • 617
  • 5
  • 4