1、htop : interactive process viewer /交互式进程查看器
htop [-dChustv]
options:
-d --delay=DELAY ,Delay between updates, in tenths of seconds/ 设置数据更新频率
>>>htop -d 1
-p --pid=PID,PID...Show only the given PIDs/显示指定pid进程信息
>>>htop -p 1 ##只显示pid=1的进程信息
-s --sort-key COLUMN, Sort by this column (use --sort-key help for a column list) /按照指定列排序
-u --user=USERNAME,Show only the processes of a given user./只显示指定用户的进程;
-t --tree, Show processes in tree view ./按照树状形式展示进程 ;
除了常用的选项之外,还有交互式指令可用:
s : Trace process system calls; /跟踪进程的系统调用情况,F8:AutoRoll 自动刷新
l : Display open files for a process:/展示进程打开的文件,确保lsof 已安装;
u : Show only processes owned by a specified user. / 展示指定用户的进程
M : Sort by memory usage (top compatibility key)./htop结果按照内存使用率排序;
P :Sort by CPU usage ./htop结果按照CPU使用率排序,默认选项;
T :Sort by time (top compatibility key). / 根据CPU累计时间进行排序
htop 还支持鼠标操作,如下图,可点击F1 帮助,F2 进行设置,F5树状显示,F9 直接发送kill 信号格进程 等;
如: 查找ping 进程,点击F3 ,搜索ping ,enter ;
点击 F9 kill ,选择发送的信号, 如15 ,enter , 即可杀掉ping进程;
2、vmstat: Report virtual memory statistics ,include processes, memory, paging, block IO, traps, disks and cpu activity. /报告进程、内存、内存页,IO、磁盘、CPU等状态;
vmstat [options] [delay [count]]
options:
-a, --active :Display active and inactive memory ./展示活动和不活动的内存;
-d, --disk : Report disk statistics / 报告硬盘数据
-t, --timestamp : Append timestamp to each line ./ 在每次的结果后面加上时间戳;
vmstat [delay [count]] : 默认情况下,只执行一次结果;可以指定刷新频率及次数来显示结果,如下:
以上每列的含义:
procs:
r: The number of runnable processes (running or waiting for run time)./正处于running或者等待状态的进程数;
b: The number of processes in uninterruptible sleep. /不可中断睡眠的进程数;因IO阻塞的进程数;
Memory:
swpd: the amount of virtual memory used. / 正在被使用的swap内存大小;
free: the amount of idle memory./空闲的物理内存大小;
buff: the amount of memory used as buffers./ 被作为buffers的内存大小;
cache: the amount of memory used as cache./被作为cache的内存大小;
Swap:
si: Amount of memory swapped in from disk (/s)./ swap分区数据 存入 物理内存的速率
so: Amount of memory swapped to disk (/s). / 物理内存存入swap分区数据的速率
IO:
bi: Blocks received from a block device (blocks/s). /从硬盘读入数据的速率
bo: Blocks sent to a block device (blocks/s). /从硬盘设置读出数据的速率
System
in: The number of interrupts per second, including the clock. /中断速率
cs: The number of context switches per second. /上下文切换速率
CPU:
us: Time spent running non-kernel code. (user time, including nice time)/ CPU 执行用户代码的时间;
sy: Time spent running kernel code. /CPU执行内核代码消耗的时间
id: Time spent idle. / CPU空闲时间
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. / 等待IO的时间
st: Time stolen from a virtual machine. /被虚拟化占用的CPU时间;