一、统计sleep状态的进程.

c233 plugins # ps -elf|head -1
F S UID     PID   PPID C PRI   NI       ADDR   SZ    WCHAN    STIME TTY TIME     CMD
4 S root 28149  4204    0 80     0             -       16283    poll_s       Jul05 ? 00:00:00   sshd: root

c233 plugins # ps -efl|awk '$2~/S/{print $0}'|wc -l                     //-l              long format. 
73
解释===>
(1)F列.

PROCESS FLAGS
The sum of these values is displayed in the "F" column, which is provided by the flags output specifier.
1 forked but didn't exec
4 used super-user privileges

(1)S列.

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.

(3)C列.C     pcpu         cpu utilization

(4)

command    COMMAND  see args. (alias args, cmd).

sz                    SZ       size in physical pages of the core image of the process. This
includes text, data, and stack space. Device mappings are currently
excluded; this is subject to change. See vsz and rss.

(5)WCHAN列.

wchan           WCHAN     name of the kernel function in which the process is sleeping,
a "-" if the process is running, or a "*" if the process is
multi-threaded and ps is not displaying threads.

二、统计当前运行的线程总数."-L"

c233 plugins # ps -eLf|grep -v $$|wc -l                                  //-L              Show threads, possibly with LWP and NLWP columns

646

c233 plugins # ps -eLf|grep -v $$|tail

UID        PID    PPID    LWP    C   NLWP   STIME TTY   TIME     CMD

root      1    689    0    36      Jul01 ? 00:00:06   /usr/sbin/nscd
root       1    690    0    36      Jul01 ? 00:00:06   /usr/sbin/nscd
root       4204 28149   0    1        Jul05 ? 00:00:00     sshd: root

NLWP (number of threads)

LWP (thread ID)

c233 plugins # ps -ef|grep nscd
root 23678 1 0 Jun30 ? 00:15:32 /usr/sbin/nscd

三、Linux下查看某个进程的线程数量.

1.根据进程号进行查询:

# pstree -p 进程号      //-p pid

# top -Hp 进程号        //-H : Threads toggle

2.根据进程名字进行查询:

# pstree -p `ps -e | grep sshd | awk '{print $1}'`

# pstree -p `ps -e | grep sshd | awk '{print $1}'` | wc -l

四、统计正在sleeop的线程总数.

d231 ~ # for i in `ps aux|awk '$8~/S/{print $2}'`;do             //如何让其累加??如何查看正在运行的线程????
> m=`pstree -p $i|wc -l`
> echo $m
> done
No such user name: PID
0
1184
42
1
1
13
1
1
1
1
1
1
1
1
2
2
0
0
61
1
8
1
1088
1

ps命令实用方法.ps -l ps -L详解的更多相关文章

  1. ANDROID L——Material Design详解(UI控件)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! Android L: Google已经确认Android L就是Android Lolli ...

  2. [转]ANDROID L——Material Design详解(动画篇)

    转载请注明本文出自大苞米的博客(http://blog.csdn.net/a396901990),谢谢支持! 转自:http://blog.csdn.net/a396901990/article/de ...

  3. Java线程通讯方法之wait()、nofity() 详解

    Java线程通讯方法之wait().nofity() 详解 本文将探讨以下问题: synchronized 代码块使用 notify()与notifyAll()的区别 Java wait(),noti ...

  4. 命令创建.net core3.0 web应用详解(超详细教程)

    原文:命令创建.net core3.0 web应用详解(超详细教程) 你是不是曾经膜拜那些敲几行代码就可以创建项目的大神,学习了命令创建项目你也可以成为大神,其实命令创建项目很简单. 1.cmd命令行 ...

  5. UIViewController中各方法调用顺序及功能详解

    UIViewController中各方法调用顺序及功能详解 UIViewController中loadView, viewDidLoad, viewWillUnload, viewDidUnload, ...

  6. jQuery插件开发的两种方法及$.fn.extend的详解(转)

    jQuery插件开发的两种方法及$.fn.extend的详解 jQuery插件开发分为两种:1 类级别.2 对象级别,下面为大家详细介绍下   jQuery插件开发分为两种: 1 类级别 类级别你可以 ...

  7. 【转载】Linux命令-自动挂载文件/etc/fstab功能详解[转]

    博客园 首页 新随笔 联系 订阅 管理 随笔 - 322  文章 - 0  评论 - 19 Linux命令-自动挂载文件/etc/fstab功能详解[转]     一./etc/fstab文件的作用 ...

  8. Windows命令(ping、telnet、netstat详解)

    转至:https://www.cnblogs.com/lisuyun/articles/5864744.html netstat详解转自http://wsmajunfeng.iteye.com/blo ...

  9. JMeter学习-023-JMeter 命令行(非GUI)模式详解(一)-执行、输出结果及日志、简单分布执行脚本

    前文 讲述了JMeter分布式运行脚本,以更好的达到预设的性能测试(并发)场景.同时,在前文的第一章节中也提到了 JMeter 命令行(非GUI)模式,那么此文就继续前文,针对 JMeter 的命令行 ...

随机推荐

  1. 蜗牛慢慢爬 LeetCode 22. Generate Parentheses [Difficulty: Medium]

    题目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parent ...

  2. 第十二周(12.01-12.04)----final评论I

    1.  约跑App——nice!:作为final发布讲说的第一组,nice团队很不容易.虽然很早就来到了发布场地,为发布做准备.但是准备上还是有些不足.对于摄像头的不稳定,nice没有很好的解决.在演 ...

  3. PAT 甲级 1057 Stack

    https://pintia.cn/problem-sets/994805342720868352/problems/994805417945710592 Stack is one of the mo ...

  4. linux 开机直接进入命令行

    一.图形界面和命令行切换 linux系统在启动图形化界面后,可以在图形界面和命令行之间来回切换,linux提供了6个命令行终端(terminal或Console),分别为tty1——tty6,使用Ct ...

  5. bower安装和使用

    bower的安装 1,首先在我的系统 安装 nodejs.因为我的系统是windows,还需要安装msysgit,注意图二中的选项   msysgit   Git setup 2,之后就可以用npm包 ...

  6. Codeforces Round #530 Div. 1 自闭记

    A:显然应该让未确定的大小尽量大.不知道写了啥就wa了一发. #include<iostream> #include<cstdio> #include<cmath> ...

  7. BZOJ1018 SHOI2008堵塞的交通(线段树)

    动态图的连通性当然是可以用LCT维护的.但这相当的不优美,毕竟这样做没有用到任何该图的性质,LCT自带的大常数也会使其跑得非常慢. 考虑用线段树维护区间左右端四个点之间各自的连通性(仅经过该区间内路径 ...

  8. bzoj1038

    这是一道非常有意思的题目 Description 致力于建设全国示范和谐小村庄的H村村长dadzhi,决定在村中建立一个瞭望塔,以此加强村中的治安.我们将H村抽象为一维的轮廓.如下图所示 我们可以用一 ...

  9. BZOJ 3625: [Codeforces Round #250]小朋友和二叉树

    3625: [Codeforces Round #250]小朋友和二叉树 Time Limit: 40 Sec  Memory Limit: 256 MBSubmit: 304  Solved: 13 ...

  10. 部署kube-prometheus,添加邮件报警

    这个项目出自coreos,已经存在很久了,第一次尝试的时候还很简陋,现在完善了很多. 项目提供了一键部署脚本,跑起来并不难,不过个人感觉要真正掌握并灵活使用并不是很容易. kube version: ...