ARTICLE

Using Top More Efficiently
Contributed by Mulyadi Santosa in Misc on 2006-03-28 04:05:13
Page 4 of 5

E. Multi view are better than one?

In different situations, sometimes we want to monitor different system property. For example, at one time you want to monitor %CPU and cpu time spent by all tasks. At another time, you want to monitor resident size and total page faults of all tasks. Rapidly press 'f' and change the visible fields? I don't think this is a smart choice.

Why don't you use Multiple Windows mode? Press 'A' (upper case) to switch to multi windows view. By default, you will see 4 different set of field groups. Each field groups has a default label/name:

  • 1st field group: Def
  • 2nd field group: Job
  • 3rd field group: Mem
  • 4th field group: Usr

1st field group is the usual group you see in single window view, while the rest are hidden. Inside multi window mode, press 'a' or 'w' to cycle through all the available windows. Pay attention, switching to another window also change the active window (also known as current window). If you are not sure which one is currently the active one, just look at the first line of top's display (at the left of current time field). Another way to change active window is by pressing 'G' followed by windows number (1 to 4).

Active window is the one which react to user input, so make sure to select your preferred window first before doing anything. After that, you can do anything exactly like you do in single window mode. Usually, what you want to do here is customizing field display, so just press 'f' and start customizing.

If you think 4 is too much, just switch to a field group and press '-' to hide it. Please note, even you hide current field group, that doesn't mean you also change the active group. Press '-' once again to make current group visible.

If you are done with multi window mode, press 'A' again. That also make active group as the new field group of single window mode.

F. "How come there is only so few free memory on my Linux PC?"

Come to same question? No matter how much you put RAM in your motherboard, you quickly notice the free RAM is reduced so fast. Free RAM miscalculation? No!

Before answering this, first check the memory summary located on the upper side of top's display (you may need to press 'm' to unhide it). There, you will find two fields: buffers and cached. "Buffers" represent how much portion of RAM is dedicated to cache disk block. "Cached" is similar like "Buffers", only this time it caches pages from file reading. For thorough understanding of those terms, refer to Linux kernel book like Linux Kernel Development by Robert M. Love.

It is enough to understand that both "buffers" and "Cached" repre- sent the size of system cache. They dynamically grow or shrink as requested by internal Linux kernel mechanism.

Besides consumed by cache, the RAM itself is also occupied by application data and code. So, to conclude, free RAM size here means RAM area that isn't occupied by cache nor application data/code. Generally, you can consider cache area as another "free" RAM since it will be shrunk gradually if the application demands more memory.

On the task point of view, you might wonder which field truly represent memory consumption. VIRT field? certainly not! Recall that this field represent everything inside task address space, including the related shared libraries. After reading top source code and proc.txt (inside Documentation/filesystem folder of kernel source's tree), I conclude that RSS field is the best field describing task's memory consumption. I said "best" because you should consider it as approximation and isn't 100% accurate on all time.

G. Working with many saved configurations

Wanna keep several different configuration of top so you can easily switch between preconfigured display? Just create symbolic link to the top binary (name it anything you like:

# ln -s /usr/bin/top /usr/bin/top-a

Then run the new "top-a". Do the tweak and press 'W' to save the configuration. It will be saved under ~/.top-arc (the format is your top alias name+'rc').

Now run the original top to load your first display alternative, top-a for the second one and so on.



Article Index
Using Top More Efficiently
Fast or slow update?
Fields we need
Multi view are better than one?
Conclusion
 
Discussion(s)
Network engineer
Written by kourosh on 2008-01-28 13:32:24
Hope you don't mind but not enough examples given
Discuss! Reply!

Network Engineer
Written by Mark on 2008-02-07 10:43:18
Quote:

Hope you don't mind but not enough examples given





Congratulations on the most polite criticism ever delivered on the web. Well, at least in my travels, I've never seen a critique of an article so gently worded. Anyway, Kudos to you for your politeness.

As it turns out, I beg to differ with your critique. IMHO, the article had sufficient examples: Just enough to whet your appetite and get you reading the man page for more.
Discuss! Reply!

RE:
Written by Ritwik Malvi on 2008-02-11 17:14:16
Quote:

Quote:

Hope you don't mind but not enough examples given





Congratulations on the most polite criticism ever delivered on the web. Well, at least in my travels, I've never seen a critique of an article so gently worded. Anyway, Kudos to you for your politeness.

As it turns out, I beg to differ with your critique. IMHO, the article had sufficient examples: Just enough to whet your appetite and get you reading the man page for more.





Is there any way to monitor just the top 10 processes in Linux(like using the -n switch in Unixware)?
Discuss! Reply!

RE:
Written by Ritwik Malvi on 2008-02-11 17:15:41
Quote:

Quote:

Quote:

Hope you don't mind but not enough examples given





Congratulations on the most polite criticism ever delivered on the web. Well, at least in my travels, I've never seen a critique of an article so gently worded. Anyway, Kudos to you for your politeness.

As it turns out, I beg to differ with your critique. IMHO, the article had sufficient examples: Just enough to whet your appetite and get you reading the man page for more.





Is there any way to monitor just the top 10 processes in Linux(like using the -n switch in Unixware)?





I meant the top 10 processes consuming CPU (the top 10 processes from the top -S command)
Discuss! Reply!

Thanks!
Written by Anonymous bin Ich on 2008-04-04 03:17:25
Good article.

It would be nice if you added once sentence descriptions to all the Fields of top.

(Ok, I know that higher NICE value means lower priority, but what about higher PR value?)
Discuss! Reply!

Stop the loop?
Written by Sonya* on 2008-04-21 05:12:51
I typed top -b and it was indefintely loop as you said, but how can I stop this loop? I had to kill the putty session to quit it. Thank you.
Discuss! Reply!

Processes and Loop
Written by Jorge Chollet on 2008-04-22 18:53:02
Quote:

I typed top -b and it was indefintely loop as you said, but how can I stop this loop? I had to kill the putty session to quit it. Thank you.





@Ritwik Malvi: You can enter top in interactive mode (just type 'top' without parameters) and type 'n', then enter the number of processes you want to see.

@Sonya: Just press Ctrl+C. I use Putty myself at work.
Discuss! Reply!

a
Written by mark on 2008-05-06 19:24:16
Quote:

I typed top -b and it was indefintely loop as you said, but how can I stop this loop? I had to kill the putty session to quit it. Thank you.






I have the same problem. How do you stop top??
Discuss! Reply!

a
Written by Mark on 2008-05-06 19:26:17

I just found your reply to use control c to stop top.

That works great! Thanks!!
Discuss! Reply!

top process states
Written by pavan on 2008-05-15 09:05:04
can anybody tell what is "SWN" state of a process
Discuss! Reply!

Monitor process via command name?
Written by viettrung on 2008-07-04 10:21:40
Hi,

Thank you for a useful article.

I just want to know whether it is possible to monitor a process via its (command) name rather than its process identifier? If so, how?

Regards,

.viettrung.
Discuss! Reply!