IT技术博客大学习 共学习 共进步
全部 移动开发 后端 数据库 AI 算法 安全 DevOps 前端 设计 开发者

查看 CPU, Memory, I/O and NetFlow

生活在别处 2011-06-23 13:49:53 累计浏览 8,012 次
本机暂存

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

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

同分类推荐文章

  1. How to Set Up Homebrew Tap for Private CLI Tools: A Complete Guide (2026-05-27 02:13:03)
  2. WARNING: detected duplicate paths to the same disk导致crs无法正常启动故障解决 (2026-05-24 22:24:49)
  3. Terraform 极简入门:从 AWS-CLI 到基础设施即代码(IaC) (2026-05-20 08:00:00)

查看更多 DevOps 文章 →

建议继续学习

  1. WEB系统需要关注的一些点 (累计阅读 17,868)
  2. 批量添加主机到cacti+nagios的监控报警系统中 (累计阅读 14,787)
  3. 我常用的主机监控shell脚本 (累计阅读 13,273)
  4. Cacti 添加 Apache 监控 (累计阅读 9,110)
  5. Linux常用系统信息查看命令 (累计阅读 8,566)
  6. memory prefetch浅析 (累计阅读 7,367)
  7. 使用nginx记日志 (累计阅读 6,708)
  8. 读腾讯大讲堂 (累计阅读 6,082)
  9. SSD磨损数据的分析报告 (累计阅读 5,102)
  10. 通过『iostat -dx 1』命令监控IO性能 (累计阅读 5,105)