top命令经常用来监控linux的系统状况,是常用的性能分析工具,能够实时显示系统中各个进程的资源占用情况。
[root@sc-chenlu lianxi]# top
top - 10:59:50 up 1 day, 11:44, 2 users, load average: 0.02, 0.05, 0.01
Tasks: 155 total, 1 running, 154 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.2 us, 0.2 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.2 hi, 0.2 si, 0.0 st
KiB Men : 1863032 total, 1481720 free, 232592used, 1448720 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0used. 1478588 avail Men
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6932 root 20 0 0 0 0 I 0.3 0.0 0:07.32 kworker/1:0-events
7189 root 20 0 65628 4360 3720 R 0.3 0.1 0:00.07 top
1 root 20 0 183752 11452 8944 S 0.0 0.3 0:04.89 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.08 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
us —— 是用户进程消耗的cpu资源 user process
sy ——是操作系统的进程消耗的cpu资源 system process
ni —— 改变过优先级的进程占用CPU的百分比
id ——是表示cpu的空闲情况 idle 空闲
wa —— IO等待占用CPU的百分比
hi ———硬中断占用CPU的百分比Hardware IRQ
si ———软中断占用CPU的百分比Software Interrupts
(1) 硬中断
由与系统相连的外设(比如网卡、硬盘)自动产生的。主要是用来通知操作系统系统外设状态的变化。比如当网卡收到数据包的时候,就会发出一个中断。我们通常所说的中断指的是硬中断(hardirq)。
(2) 软中断
为了满足实时系统的要求,中断处理应该是越快越好。linux为了实现这个特点,当中断发生的时候,硬中断处理那些短时间就可以完成的工作,而将那些处理事件比较长的工作,放到中断之后来完成,也就是软中断(softirq)来完成。
内存:memory 总的内存大小 空余的内存大小 使用的 缓存使用的内存
buffer: memory data --》disk --》写的数据
cache: disk data --》memory --》读的数据
cache和buffer 都叫缓存
avail Mem :还可以给其他的程序使用的内存: available memory
avail Mem = free + buff/cache 还可以使用的空间
total = free+used+buffer/cache