原文地址:http://blogread.cn/it/article.php?id=3908&f=sa

iostat 查看磁盘 I/O

[root@localhost ~]# iostat -d -x 2
                             extended device statistics
device mgr/s mgw/s    r/s    w/s    kr/s    kw/s   size queue   wait svc_t  %b
hda        0     0    0.0    0.9     0.1     5.4    6.3   0.0    4.7   0.9   0
                             extended device statistics
device mgr/s mgw/s    r/s    w/s    kr/s    kw/s   size queue   wait svc_t  %b
hda        0     3    0.0    2.0     0.0    20.0   10.0   0.0    0.8   0.5   0
 ......

命令释意: 查看磁盘 I/0 情况,且每两秒刷新一次

[root@localhost ~]# vmstat 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0    284  68700 165876 416748    0    0     0     5    1    1  0  0 100  0  0
 ......

命令释意: 查看CPU使用情况的命令, 每 5 秒刷新一次,最右侧列为 CPU 的占用率的数据

top 查看进程占有率

[root@localhost ~]# top

然后在 top 的命令内部命令栏输入shift+p or P

top - 13:38:52 up 102 days,  4:17,  1 user,  load average: 0.00, 0.00, 0.00
Tasks:  81 total,   2 running,  79 sleeping,   0 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:   1035292k total,   966592k used,    68700k free,   165876k buffers
Swap:  2096472k total,      284k used,  2096188k free,   416760k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4875 root      15   0  2192 1000  800 R  0.3  0.1   0:00.15 top
    1 root      15   0  2060  620  532 S  0.0  0.1   0:01.65 init
    2 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0
.......

命令释意: 查看进程处理器占用率情况,并对其进行排序

free 查看内存使用情况

[root@localhost ~]# free
             total       used       free     shared    buffers     cached
Mem:       1035292     966592      68700          0     165876     416768
-/+ buffers/cache:     383948     651344
Swap:      2096472        284    2096188

命令释意: 查看内存使用情况

top 查看进程内存使用

[root@localhost ~]# top

然后在 top 的命令内部命令栏输入shift+m or M

top - 13:48:52 up 102 days,  4:27,  1 user,  load average: 0.00, 0.01, 0.00
Tasks:  81 total,   2 running,  79 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.3%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1035292k total,   966592k used,    68700k free,   165876k buffers
Swap:  2096472k total,      284k used,  2096188k free,   416784k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 4128 root      34  19  280m 266m 2112 S  0.0 26.4   1:48.40 yum-updatesd
 8314 www       18   0  171m  34m  34m S  0.0  3.4   0:06.03 memcacheq
 8280 www       15   0 88084  34m  588 S  0.0  3.4   0:01.23 memcached
10907 mysql     15   0  122m  16m 3892 S  0.0  1.7   0:25.29 mysqld
......

命令释意: 查看进程内存占用率情况,并对其进行排序

获得针对某个 Interface 的网络流量

[root@localhost ~]# date;ifconfig eth0
Sun Mar 13 13:51:29 CST 2011
eth0      Link encap:Ethernet  HWaddr 00:50:56:A4:0D:89
          inet addr:172.10.7.215  Bcast:172.10.7.255  Mask:255.255.248.0
          inet6 addr: fe80::250:56ff:fea4:d89/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72113071 errors:12213 dropped:30790 overruns:0 frame:0
          TX packets:1062902 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3311165612 (3.0 GiB)  TX bytes:101244262 (96.5 MiB)
          Interrupt:59 Base address:0x2000

[root@localhost ~]# date;ifconfig eth0
Sun Mar 13 13:53:13 CST 2011
eth0      Link encap:Ethernet  HWaddr 00:50:56:A4:0D:89
          inet addr:172.10.7.215  Bcast:172.10.7.255  Mask:255.255.248.0
          inet6 addr: fe80::250:56ff:fea4:d89/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:72113528 errors:12213 dropped:30790 overruns:0 frame:0
          TX packets:1062968 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3311204659 (3.0 GiB)  TX bytes:101285190 (96.5 MiB)
          Interrupt:59 Base address:0x2000

命令释意: 通过比较两个时间网络接口的 RX 和 TX 数据来获得针对某个 Interface 的网络流量

来自yaronspace.cn  本文链接:http://yaronspace.cn/blog/archives/1331