操作系统诊断

1.CPU

如果%sys比较高,可能的原因有:换页(换页时%wio一般不会高)、出现栓锁、bug等

(1)iostat监控所有CPU的平均信息

# iostat -x 1 2
Linux 2.6.32-358.el6.x86_64 (oracledb1)         03/22/2016      _x86_64_        (40 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.37    0.00    0.21    0.07    0.00   99.35

Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
sda               0.00    90.78    0.18   12.60    38.13   822.64    67.34     0.30   23.68   0.26   0.34
dm-0              0.00     0.00    0.16   78.40    37.30   627.20     8.46     0.25    3.14   0.03   0.22

 (2)vmstat查看CPU队列信息

# vmstat
procs --------------memory------------ ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd     free   buff    cache   si   so    bi    bo   in   cs  us sy id wa st
 4  0      0 61348052 368504 31984096    0    0     7     4    0    0   0  0 99  0  0

(3)mpstat能查看单个和所有的CPU信息

# mpstat 
Linux 2.6.32-358.el6.x86_64 (odb)         03/22/2014      _x86_64_        (40 CPU)

09:24:36 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest   %idle
09:24:36 AM  all    0.37    0.00    0.21    0.07    0.00    0.01    0.00    0.00   99.35

(4)top(top命令后,按1可以查看单个cpu信息)

top - 09:26:57 up 86 days, 20:44,  1 user,  load average: 0.07, 0.11, 0.09
Tasks: 1132 total,   1 running, 1131 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.1%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  99040048k total, 34672768k used, 64367280k free,    15112k buffers
Swap: 70352888k total,        0k used, 70352888k free, 28789784k cached

2.内存

top、vmstat、free等命令

Linux中查看某个进程占用内存的情况,执行如下命令即可,将其中的[pid]替换成相应进程的PID号:

cat /proc/[pid]/status

# ps aux

RSS:进程实际占用物理内存大小
VSZ:任务虚拟地址空间的大小

# ps aux
USER       PID %CPU %MEM      VSZ      RSS TTY  STAT START   TIME COMMAND
root         1  0.0  0.0    19348     1460 ?      Ss  2015   1:21 /sbin/init
root         2  0.0  0.0        0        0 ?       S  2015   0:00 [kthreadd]
root         3  0.0  0.0        0        0 ?       S  2015   0:31 [migration/0]
oracle    8747  0.0 13.4 30005180 13292640 ?      Ss  2015  29:07 oracleorcl1 (LOCAL=NO)
oracle    8749  0.0 13.5 30005184 13385272 ?      Ss  2015  29:13 oracleorcl1 (LOCAL=NO)
oracle    8751  0.0 13.5 30005184 13460944 ?      Ss  2015  30:15 oracleorcl1 (LOCAL=NO)
oracle    8765  0.0 13.3 30005184 13183100 ?      Ss  2015  29:14 oracleorcl1 (LOCAL=NO)
oracle    8810  0.0 13.5 30005180 13434660 ?      Ss  2015  29:22 oracleorcl1 (LOCAL=NO)

3.IO
 vmstat、iostat、sar等

4.网络

监控网卡上的丢包和BUFFER OVERFLOW,监控网络流量

# sar -n DEV  1 2
Linux 2.6.32-358.el6.x86_64 (odb)         03/22/2014      _x86_64_        (40 CPU)

09:48:54 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
09:48:55 AM        lo     37.00     37.00     22.76     22.76      0.00      0.00      0.00
09:48:55 AM      eth0     14.00      9.00      1.10      0.82      0.00      0.00      0.00
09:48:55 AM      eth1    164.00    153.00    176.77    161.36      0.00      0.00      0.00
09:48:55 AM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00

09:48:55 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
09:48:56 AM        lo      6.00      6.00      9.54      9.54      0.00      0.00      0.00
09:48:56 AM      eth0     17.00      7.00      1.89      1.27      0.00      0.00      2.00
09:48:56 AM      eth1     30.00     34.00     15.01     22.64      0.00      0.00      0.00
09:48:56 AM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
Average:           lo     21.50     21.50     16.15     16.15      0.00      0.00      0.00
Average:         eth0     15.50      8.00      1.50      1.05      0.00      0.00      1.00
Average:         eth1     97.00     93.50     95.89     92.00      0.00      0.00      0.00
Average:         eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00
原文地址:https://www.cnblogs.com/abclife/p/5304989.html