Linux学习笔记
cat /proc/loadavg
查看系统负载命令
命令详解:
/proc文件系统是一个虚拟的文件系统,不占用磁盘空间,它反映了当前操作系统在内存的运行情况,查看/proc下的文件可以了解到系统的运行状态。
[root@VM-0-13-centos ~]# cat /proc/loadavg
0.00 0.01 0.05 4/206 19458
前三个数字是1、5、15分钟内的平均进程数。
第四个值的分子是正在运行的进程数,分母是进程总数,最后一个是最近运行的进程ID号。
这里的平均负载也就是可运行的进程平均数。
pstree
pstree命令以树状图的形式展示进程间的关系,ps命令可以显示当前正在运行的那些进程的信息,但是对于它们之间的关系显示得不够清晰。在Linux系统中,系统调用fork可以创建进程,通过子shell也可以创建进程。
以下是该工具手册提到的内容:
pstree shows running processes as a tree. The tree is rooted at either
pid or init if pid is omitted. If a user name is specified, all
process trees rooted at processes owned by that user are shown.
pstree visually merges identical branches by putting them in square
brackets and prefixing them with the repetition count, e.g.
init-+-getty
|-getty
|-getty
`-getty
becomes
init---4*[getty]
Child threads of a process are found under the parent process and are
shown with the process name in curly braces, e.g.
icecast2---13*[{icecast2}]
If pstree is called as pstree.x11 then it will prompt the user at the
end of the line to press return and will not return until that has hap?
pened. This is useful for when pstree is run in a xterminal.
Certain kernel or mount parameters, such as the hidepid option for
procfs, will hide information for some processes. In these situations
pstree will attempt to build the tree without this information, showing
process names as question marks.
pstree -up
可以看到所有的进程都依附在systemd这个进程下面,它的进程PID是1,因为它是由Linux内核主动调用的一个进程。可以从中看出每个进程的PID。
而且,1727这个进程有2个子进程,分别是1733、1734
1734又有3个子线程。
pstree -c
强制pstree在输出中展开相同的子树