GagA// 0n D nEt

It is currently Tue Aug 21, 2018 10:15 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux: Display Swap Usage on per process basis using "top"
PostPosted: Tue Apr 14, 2009 1:37 pm 
Offline

Joined: Wed Jul 18, 2007 1:14 am
Posts: 181
We normally use the free command or some other commands to check for the memory utilization and the swap memory consumption. However, at times we find it difficult to find what process is consuming what part of the swap memory. We can achieve this via the top command.

The simple top command will provide you the dynamic output of the processes running on the server. But when tweaked and applied with some commands, it will display the swap memory consumption on per process basis. Following is how you can accomplish this:

After issuing the top command, you need to press the f key which basically allows you to add or remove Fields/Columns from the output for top command.

Once done that you will get a list of fields which can be added with various different alphabets. You will find the following in the given output:
Code:
  p: SWAP       = Swapped size (kb)

All you have to do is, hit p and then press the enter key. This will return you to the output for top command with additional field of "SWAP" in it.

The following is how the output will look like from the top command:
Code:
top - 19:06:29 up 1 day,  6:05,  5 users,  load average: 0.54, 0.30, 0.21
Tasks: 151 total,   1 running, 150 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.2%us,  1.6%sy,  0.0%ni, 91.1%id,  0.0%wa,  0.2%hi,  0.0%si,  0.0%st
Mem:   2062160k total,  1901188k used,   160972k free,   157844k buffers
Swap:  4194296k total,     4840k used,  4189456k free,   864716k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  SWAP COMMAND                                                                         
27413 root      20   0  331m 150m  28m S    8  7.5   4:01.31 181m firefox
5311 root      20   0  560m 163m  12m S    8  8.1  50:36.30 397m Xorg
5835 gagan     20   0 31024  22m 7504 S    1  1.1   8:13.29 7768 compiz.real
5881 gagan     20   0 24368  11m 8620 S    1  0.6   0:44.46  11m multiload-apple
5954 gagan     20   0 82824  26m  12m S    1  1.3   0:10.06  54m gnome-terminal
24398 gagan     20   0 3068m  47m  23m S    1  2.3   0:29.86 3.0g pidgin
27886 root      20   0  2416 1176  880 R    1  0.1   0:00.16 1240 top
5850 gagan     20   0 75552  26m  14m S    0  1.3   2:36.44  47m gnome-panel
6143 gagan     20   0 46172  23m  11m S    0  1.2   2:21.15  21m xchat
    1 root      20   0  3056 1896  576 S    0  0.1   0:01.16 1160 init


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group