The Artima Developer Community
Sponsored Link

Python Buzz Forum
Get On Top

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Micah Elliott

Posts: 106
Nickname: mde
Registered: Feb, 2007

Micah Elliott is a hacker-entrepreneur starting up in Portland
Get On Top Posted: Jun 15, 2008 5:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Micah Elliott.
Original Post: Get On Top
Feed Title: Micah Elliott
Feed URL: http://feeds.feedburner.com/MicahElliott
Feed Description: Follow Micah as he makes connections around the Portland area, participates in community hacking events, explores the blogosphere, bounces ideas around, and tries to change the world by catching a big wave.
Latest Python Buzz Posts
Latest Python Buzz Posts by Micah Elliott
Latest Posts From Micah Elliott

Advertisement
I've used top for years to monitor machine activity. It's grown some new features and behavior in the last few years that you might not be aware of.

Good ol' top. For years it's been the cornerstone of process control. It's the first place we turn to hunt down a rogue process, or just to watch how resources are consumed. Sure, you could use a handful of GUI tools, but I frequently find myself working strictly in a terminal on remote machines, where top is indispensable. This is a short overview of top's most important features that weren't obvious to me until I got to practicing for the LPI exam a short while back. Now I'm making use of them quite regularly. To save you from wading through the 1,000-line manpage, here are the most useful interactive commands (you don't have to worry about the CLI options).
  • z -- Turn on color. Beautiful! Don't change them unless you're looking to waste a lot of time
  • s -- This is the refresh interval. The default of 3 seconds can leave you puzzled. I like to set it to one or half a second. An alternative is to just press a bunch of times whenever you want to see an update.
  • 1 -- Change the number of processors shown. Though not a default, this is critical now that every machine we get on has 2 to 16 procs.
  • H -- Show threads. Try looking at Apache with and without this.
  • i -- Ignore idle processes. This helps you focus only on what's really active; and makes everything fit on the screen.
  • O -- Order by some field. The most useful sub-selections here are q (resident memory), k (%cpu), and a (pid). Setting this helps keep your list from bouncing its order all around.
  • c -- Show whole command. Essential when you've got multiples of a similar command running.
  • u -- Only show what's happening with a single user. That's often $USER (you!), or some other luser.
  • k -- Kill a process with signal of your choosing. (Bonus: look into pgrep/pkill.)
  • ? -- Show the built-in help screen.
  • ^g -- Escape out of any menu screen.

You could have seen most of this on the built-in help screen by simply pressing h or ?. But that menu has a pretty unintuitive layout, and the above is limited to the minimal set you really need. Now that you understand how everything works, and you've got it looking nice, just press W to write the configuration for permanent use. If you're unhappy with the damage you just caused, just blow it away with: rm ~/.toprc

BONUS: You may have surprisingly seen "windows" in your top session, depending on what distro you get onto (maybe it was a Fedora?); that's how I discovered them. Press h twice to get to the windows menu. I won't get into all those details here -- I don't find the windows terribly useful, though they do appear to offer some sophisticated views. If you decide to use them, you can get started by pressing A, and then a continuously to cycle through displays. See if you can make sense of them, and then talk to me. :-)

CAVEATS: Be careful not to run top with a fast refresh during any sort of benchmarking. It can chew up a bit of CPU time. Also, top versions vary widely depending on the distro you use; you might notice some different behavior than what I've described.
(This list also makes for a great sticky, as you see in the picture.)

top is a powerful tool that gives you a lot of information. If you got this far, you should now be able to make sense of most of the cryptic display, and be able to find your way around configuring it.

Read: Get On Top

Topic: seven reasons why I love Django Previous Topic   Next Topic Topic: More on Myghty

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use