6 System Monitoring tools for Linux


1. top – Display Linux tasks
The top program provides a system summary information as well as a list of tasks currently running.

2. free – Memory usage
The free program will display amount of free and used memory in the system.

Sample (the option ‘-m’ will show the results in megabytes):
# free -m
total       used       free     shared    buffers     cached
Mem:           504        487         16          0         63        200
-/+ buffers/cache:        223        280
Swap:          486          0        485

3. w – Who is currently logged in and what they are doing
The w program displays information about the users currently logged in and their processes.
Sample:

# w
07:24:32 up 50 days, 20:00,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    ssh-server.evo.a 07:14    0.00s  0.00s  0.00s w
xaban    pts/2    support.leaseweb 07:23    8.00s  0.10s  0.00s nano -w /home/xaban/example
# w xaban
07:24:36 up 50 days, 20:00,  2 users,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
xaban    pts/2    support.leaseweb 07:23   12.00s  0.10s  0.00s nano -w /home/xaban/example

4. fuser – Identify which process is using a port
The fuser program displays the PID’s of processes using a the specified port
For example, you want to start a webserver on port 80, but you got a error message similiar to:

Can’t bind to port: 80. Address already in use.

With fuser you can find out which process is using port 80:

# fuser -n tcp 80
80/tcp:                600   601   602  2868  8362 12847 22598

5. iostat – Report CPU and I/O statistics
The iostat program is used for monitoring system I/O.

Sample:

# iostat
Linux 2.6.26-2-686 (how2forge.info)       04/25/2011      _i686_

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
0.29    0.85    0.12    1.29    0.00   97.45

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               1.43         0.76        38.39    3327210  168346707
sda1              0.00         0.00         0.00       2510        423
sda2              0.00         0.00         0.00        694       1160
sda3              0.02         0.01         1.64      26766    7210348
sda4              0.00         0.00         0.00          4          0
sda5              1.40         0.75        36.75    3296936  161134776

6. iptraf – Interactive traffic monitor
The iptraf program displays all TCP/UDP traffic information, very handy if you want to display network traffic statistics.
By default iptraf is not installed, please issue the following command to install iptraf:

# apt-get install iptraf
or
# yum install iptraf