Linux : how to see memory usage by various processes in segregated output format

I  am having Linux server, there are various process running the server.

I would like to know details about, the amount of memory consumed by each process.

so that  I can tune the process in simplified manner.
mac_gAdmin - Oracle Fusion Middleware suiteAsked:
Who is Participating?
 
woolmilkporcCommented:
Try this for all processes:

ps -eo pid, vsize,comm

and this for a single proces ID pid:

ps -p pid -o pid, vsize,comm

You will see the process id, the total virtual memory size in kB and the command.

Instead of (or in addition to) "vsize" you can specify "rss" to see the resident set size or "size" to see the memory size in kilobytes.

A very fine-grain memory map of a particular process ID pid can be obtained with

cat /proc/pid/smaps
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
getting below error message

[root@RDOV-BPMDEV01 ~]# ps -eo pid, vsize,comm
ERROR: Unsupported option (BSD syntax)
********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real g
0
 
ozoCommented:
Remove the space between "pid," and "vsize,comm"
0
WEBINAR: 10 Easy Ways to Lose a Password

Join us on June 27th at 8 am PDT to learn about the methods that hackers use to lift real, working credentials from even the most security-savvy employees. We'll cover the importance of multi-factor authentication and how these solutions can better protect your business!

 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
i am not getting, can you please type complete command
0
 
ozoCommented:
ps -eo pid,vsize,comm
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
1)   Can you brief me about params
2)   Can we display memory usage in MB's
0
 
woolmilkporcCommented:
ps = report about current processes

-e = select all processes

-p pid = select a particular process ID pid or list of pids. Do not combine with "-e"

-o user-defined output format:

    pid = process id
    rss = non-swapped physical memory used
    size = approximate swap space required for code+data+stack, very rough value!
    vsize = total virtual memory including currently swapped-out pages
    comm = short command (executable only)

ps itself cannot display MB, we'll have to calculate (Example: all processes, vsize):

ps -eo pid,vsize,comm | awk 'NR>1 {printf "%10s%10.2f\t%s\n",$1,$2/1024,$3}'

Open in new window

or simpler (no formatting):
ps -eo pid,vsize,comm | awk 'NR>1 {$2=$2/1024;print $0}

Open in new window

'

And sorry, the extra space was indeed a mistake (typo)!
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
wow ..what a genius you are ...

i have applied I got part output as below, very nice.
Does middle column value in MB's ?

--------------
      9660      0.67    systemmetrics
     10260    105.61    ps
     10261    103.52    awk
     15369      0.00    kworker/3:0
     27050      0.00    kworker/1:0
     28932     98.06    sshd
     28934     98.06    sshd
     28935    105.94    bash
     32495      0.00    kworker/0:0
     32714      0.00    kworker/0:1H
---------------------
0
 
woolmilkporcCommented:
Yes.

If you are a friend of nice output you can have a header and better formatting:

ps -eo pid,vsize=VSIZE_MB,comm | awk '{if(NR==1) printf "%8s%10s\t%s\n", $1,$2, $3; else printf "%8s%10.2f\t%s\n", $1, $2/1024,$3}'

Open in new window

0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
wow .. what a magic ...

highly appreciate ur work..

no words ..just great.

i advice  you one thing .. write a book with tricks sell from amazon. I am sure book get downloaded by many.
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
can this details be fetched for CPU details and its utilization ?
0
 
woolmilkporcCommented:
There are two CPU-related fields:

%cpu       cpu utilization of the process in "##.#" format. This is the cputime/realtime ratio in percent
cputime  cumulative CPU time, "[dd-]hh:mm:ss" format.

Try

ps-eo pid,%cpu,cputime

(no formatting required).
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
am getting below details

[root@RDOV-BPMDEV01 ~]# ps-eo pid,%cpu,cputime
-bash: ps-eo: command not found
0
 
woolmilkporcCommented:
Again, a typo, It's

ps -eo pid,%cpu,cputime
0
 
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
i have raised seperate request for CPU...

i wish if you could advice there in detail what I am looking for...

http://www.experts-exchange.com/Programming/System/Linux/Q_28662785.html#a40744602
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.