How to Track System Activity With top Command on Linux CentOS 5/CentOS 6/RHEL 5/ RHEL 6 server – System Performance

Top command is utility to monitor system activity interactively. When you run top from shell window, it will display all the activity processes and updates the screen. In this post i will show the usage of top command on CentOS 5/CentOS 6/RHEL 5/ RHEL 6 server to keep track system activity and to optimize the system performance.

Display top command on RHEL 6 :

[root@rhel6 ~]# top
top - 18:54:19 up 13:29,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  93 total,   1 running,  90 sleeping,   2 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1031320k total,   225804k used,   805516k free,    31120k buffers
Swap:  2064376k total,        0k used,  2064376k free,   116716k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1375 root      20   0 97768 9796 5768 S  0.3  0.9   0:03.43 httpd
 3974 root      20   0  2632 1076  868 R  0.3  0.1   0:00.08 top
    1 root      20   0  2828 1392 1196 S  0.0  0.1   0:01.81 init
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0
    4 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0
    6 root      20   0     0    0    0 S  0.0  0.0   0:00.25 events/0
    7 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cpuset
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 sync_supers
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 bdi-default
   14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.02 kblockd/0
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug
   19 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ata/0
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khubd
   23 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kseriod
   25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd
   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0
   27 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd
   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/0
   29 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/0
   34 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd
   36 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused
   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer
   67 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped
  267 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0
  268 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_1
  279 root      20   0     0    0    0 S  0.0  0.0   0:00.20 mpt_poll_0

Display top command on CentOS 5.7 :

[root@CentOS57 ~]# top
top - 18:57:39 up 10:04,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  73 total,   1 running,  70 sleeping,   2 stopped,   0 zombie
Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1034700k total,    86916k used,   947784k free,     7292k buffers
Swap:  2096472k total,        0k used,  2096472k free,    36104k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    1 root      15   0  2160  676  584 S  0.0  0.1   0:00.93 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0
    4 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 events/0
    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khelper
    6 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kthread
    9 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/0
   10 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid
  173 root      17  -5     0    0    0 S  0.0  0.0   0:00.00 cqueue/0
  176 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khubd
  178 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod
  244 root      21   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd
  245 root      22   0     0    0    0 S  0.0  0.0   0:00.00 pdflush
  246 root      15   0     0    0    0 S  0.0  0.0   0:00.01 pdflush
  247 root      17  -5     0    0    0 S  0.0  0.0   0:00.00 kswapd0
  248 root      17  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0
  466 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kpsmoused
  492 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 mpt_poll_0
  493 root      19  -5     0    0    0 S  0.0  0.0   0:00.00 mpt/0
  494 root      19  -5     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_0
  497 root      19  -5     0    0    0 S  0.0  0.0   0:00.00 ata/0
  498 root      19  -5     0    0    0 S  0.0  0.0   0:00.00 ata_aux
  505 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kstriped
  514 root      10  -5     0    0    0 S  0.0  0.0   0:00.17 kjournald
  544 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kauditd
  577 root      21  -4  3004 1468  504 S  0.0  0.1   0:00.62 udevd
 1730 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kmpathd/0
 1731 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kmpath_handlerd
 1790 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kjournald
 1868 root      13  -5     0    0    0 S  0.0  0.0   0:00.00 iscsi_eh
 1896 root      18  -5     0    0    0 S  0.0  0.0   0:00.00 cnic_wq
 1911 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 ib_addr
 1918 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 ib_mcast
 1919 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 ib_inform
 1920 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 local_sa
 1923 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 iw_cm_wq

By default, top will update its screen in every seconds. You can change this interval by using d seconds options as below :

READ  How to Restart Linux Network Service

To update the screen every 5 seconds, run the “top d 5” command :

[root@rhel6 ~]# top d 5
top - 18:56:51 up 13:32,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  94 total,   1 running,  90 sleeping,   3 stopped,   0 zombie
Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1031320k total,   226064k used,   805256k free,    31136k buffers
Swap:  2064376k total,        0k used,  2064376k free,   116716k cached

To update the screen every 10 seconds, run the “top d 10” command :

[root@rhel6 ~]# top d 10
top - 18:57:21 up 13:32,  2 users,  load average: 0.00, 0.00, 0.00
Tasks:  95 total,   1 running,  90 sleeping,   4 stopped,   0 zombie
Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1031320k total,   226448k used,   804872k free,    31144k buffers
Swap:  2064376k total,        0k used,  2064376k free,   116716k cached

The screen updates every 5 to 20 seconds interval is more usefull tha the default setting, 1 second. This because update every 1 second will lists itself in its own output as the main resource consumer. If you press the h key while top is running, you will see the following output screen :

Leave a Reply

Your email address will not be published. Required fields are marked *