进程资源查看pidstat

作用

  查看全部或指定进程占用系统资源的情况,如CPU,内存、设备IO、任务切换、线程等。pidstat首次运行时显示自系统启动开始的各项统计信息,之后运行pidstat将显示自上次运行该命令以后的统计信息。用户可以通过指定统计的次数和时间来获得所需的统计信息。

使用

指定采样周期和次数

命令格式:pidstat [option] interval [count]

pidstat 3 10

指定进程(-p)

pidstat -p pid 3 10

CPU使用情况(-u)

pidstat -u 3 10

内存使用情况(-r)

pidstat -r -u 3 10

IO统计信息(-d)

pidstat -d 3 10

上下文切换统计(-w)

//指定进程上下文切换情况
pidstat -p pid -w 3 10
//指定进程内各线程上下文切换情况
pidstat -p pid -t -w 3 10

参数说明:

  • cswch/s

  每秒自愿上下文切换次数,次数变多说明任务都在等待资源,内存或者IO等存在问题;

Total number of voluntary context switches the task made per second. A voluntary context switch occurs when a task blocks because it requires a resource that is unavailable.

  • nvcswch/s

  每秒被动上下文切换次数,次数变多说明任务都在争抢CPU资源,CPU成为瓶颈;

Total number of non voluntary context switches the task made per second. A involuntary context switch takes place when a task executes for the duration of its time slice and then is forced to relinquish the processor.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章