Linux学习笔记

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在输出中展开相同的子树

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值