Notes on ScopePort

Get the most information out of your GNU/Linux processes

by Lennart on Sep.06, 2008, under Uncategorized

Sometimes it is not easy to find out what process is currently slowing down your system or why the mouse is jumping over the screen when it is supposed to follow your hand movements in a kind of gliding motion. I have collected a list of tools to find out what processes consume the most of your resources and even how to get an indication of the reason for that.

CPU and memory usage: top/htop

Most of you may already know “top”. It is the first program to fire up if the system gets unsually slow. top shows you a list of processes – ordered by their memory and CPU usage.

/usr/bin/top

/usr/bin/top

As an alternative there is an improved version of top: htop. It has many more options for sorting, searching or display and shows the general system usage in a clearly arranged way.

/usr/bin/htop

/usr/bin/htop

htop might not be a standard part of your distribution but it should be available in the repositories.

I/O usage: iotop

Sometimes programs slow down the system by using too much I/O resources (e.g. when extracting a really big tarball). When the programs don’t need much CPU resources for heavy I/O resources they might now show up in top or htop. If you want to find out e.g. what is currently hammering your hard disk buffers you can take a look at iotop: It displays processes sorted by I/O usage in a top-like way.

/usr/bin/iotop

/usr/bin/iotop

iotop might not be a standard part of your distribution but it should be available in the repositories.

MySQL and Apache

Sometimes you want to know what consumes most of your MySQL or Apache resources.

If you want to know what queries are currently executed and in what state the operation is you can use the “SHOW PROCESSLIST;” SQL command in a MySQL shell:

SHOW PROCESSLIST;

SHOW PROCESSLIST;

If your Apache has heavy load you might want to know what requests/files cause this load. There is a program “apachetop” that provides this information:

Get the most information out of your GNU/Linux processes

/usr/bin/apachetop

apachetop might not be a standard part of your distribution but it should be available in the repositories.

Finding out more about rioting processes

So you found the process that consumes the resources? Here is the ultimate solution to find out more about the process: /bin/lsof (list open files)

Here are the possibly most useful lsof modes:

Show all open files of the process with given PID: lsof -p [PID]
Show all programs that have currently opened a file: lsof [file]
Show all programs that have currently opened a file in a given directory: lsof +D [directory]
Show all programs that have a socket related to a given port: lsof -i :[port]

Get the most information out of your GNU/Linux processes

lsof -p 3773

/bin/lsof +D /var/log

/bin/lsof +D /var/log

/bin/lsof -i 12200

/bin/lsof -i :12200

Share:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • StumbleUpon
  • Technorati
  • Yigg
  • FriendFeed
  • Identi.ca
  • MySpace
  • TwitThis
:, , , , , , , , , , ,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!