关键词:
一,pidstat 查看某个进程下的所有线程
[lhdop@blog ~]$ pidstat -t -p 20756 Linux 4.18.0-80.11.2.el8_0.x86_64 (blog) 03/20/2022 _x86_64_ (4 CPU) 01:38:44 PM UID TGID TID %usr %system %guest %wait %CPU CPU Command 01:38:44 PM 1000 20756 - 0.00 0.00 0.00 0.00 0.00 1 java 01:38:44 PM 1000 - 20756 0.00 0.00 0.00 0.00 0.00 1 |__java 01:38:44 PM 1000 - 20757 0.00 0.00 0.00 0.00 0.00 0 |__java 01:38:44 PM 1000 - 20758 0.00 0.00 0.00 0.00 0.00 1 |__GC Thread#0 01:38:44 PM 1000 - 20759 0.00 0.00 0.00 0.00 0.00 2 |__G1 Main Marker 01:38:44 PM 1000 - 20760 0.00 0.00 0.00 0.00 0.00 0 |__G1 Conc#0 01:38:44 PM 1000 - 20761 0.00 0.00 0.00 0.00 0.00 1 |__G1 Refine#0 01:38:44 PM 1000 - 20762 0.00 0.00 0.00 0.00 0.00 3 |__G1 Young RemSet 01:38:44 PM 1000 - 20763 0.00 0.00 0.00 0.00 0.00 2 |__VM Thread 01:38:44 PM 1000 - 20764 0.00 0.00 0.00 0.00 0.00 3 |__Reference Handl 01:38:44 PM 1000 - 20765 0.00 0.00 0.00 0.00 0.00 1 |__Finalizer 01:38:44 PM 1000 - 20766 0.00 0.00 0.00 0.00 0.00 1 |__Signal Dispatch 01:38:44 PM 1000 - 20767 0.00 0.00 0.00 0.00 0.00 0 |__Service Thread …
参数说明:
-t Also display statistics for threads associated with selected tasks. This option adds the following values to the reports: TGID The identification number of the thread group leader. TID The identification number of the thread being monitored.
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,top查看某个进程下的线程:
[lhdop@blog ~]$ top -H -p 20756 top - 21:33:13 up 800 days, 11:29, 3 users, load average: 0.05, 0.23, 0.46 Threads: 44 total, 0 running, 44 sleeping, 0 stopped, 0 zombie %Cpu(s): 1.7 us, 0.1 sy, 0.0 ni, 98.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 15355.3 total, 406.0 free, 2331.6 used, 12617.6 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 12695.1 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 20756 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.00 java 20757 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:04.29 java 20758 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.16 GC Thread#0 20759 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.00 G1 Main Marker 20760 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.18 G1 Conc#0 20761 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.04 G1 Refine#0 20762 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:14.18 G1 Young RemSet 20763 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:02.24 VM Thread 20764 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.00 Reference Handl 20765 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.00 Finalizer 20766 lhdop 20 0 7766336 354944 28800 S 0.0 2.3 0:00.00 Signal Dispatch …
-H :Threads-mode operation Instructs top to display individual threads. Without this command-line option a summation of all threads in each process is shown.
Later this can be changed with the `H\' interactive command.
三,ps查看线程:
[lhdop@blog ~]$ ps -T -p 20756 PID SPID TTY TIME CMD 20756 20756 ? 00:00:00 java 20756 20757 ? 00:00:04 java 20756 20758 ? 00:00:00 GC Thread#0 20756 20759 ? 00:00:00 G1 Main Marker 20756 20760 ? 00:00:00 G1 Conc#0 20756 20761 ? 00:00:00 G1 Refine#0 20756 20762 ? 00:00:14 G1 Young RemSet 20756 20763 ? 00:00:02 VM Thread 20756 20764 ? 00:00:00 Reference Handl 20756 20765 ? 00:00:00 Finalizer 20756 20766 ? 00:00:00 Signal Dispatch 20756 20767 ? 00:00:02 Service Thread 20756 20768 ? 00:00:12 C2 CompilerThre 20756 20769 ? 00:00:04 C1 CompilerThre 20756 20770 ? 00:00:00 Sweeper thread 20756 20771 ? 00:00:00 Notification Th 20756 20772 ? 00:00:34 VM Periodic Tas 20756 20773 ? 00:00:00 Common-Cleaner 20756 20775 ? 00:00:00 GC Thread#1 20756 20776 ? 00:00:00 GC Thread#2 20756 20778 ? 00:00:00 GC Thread#3 20756 20781 ? 00:00:00 G1 Refine#1 20756 20782 ? 00:02:44 Log4j2-TF-10-As ...
-T Show threads, possibly with SPID column.
四,查看linux的版本:
[lhdop@blog ~]$ cat /etc/os-release NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8"
编写进程线程常用的linux命令
uname-a: 查看linux 的版本号ipcrm: 结束一个信号量等lsipc 或ipcs: 查看信号量等ipcmk:创建pstree: 查看系统所有线程pstree|grep 运行程序名: 查看对应程序的所有线程gcc1.c-g: 将原程序1.c编译成可被gdb 调试的程序gdb a.out... 查看详情
查看linux系统状态的常用命令
一、查看CPU的详细情况判断服务器CPU的情况依据如下:a. 具有相同的coreid的PUC是由同一个core的超线程。b. 具有相同的physicalid的CPU是同一个CPU封闭的线程或核心方法1:物理个CPU个数如下:以下为2个CPU[[email protected] ... 查看详情
linux系列之查看进程线程的方法(代码片段)
在window系统查看系统进程,我们一般会使用Ctrl+Shift+Esc打开系统进程监控页面,但是在Linux系统查看进程一般使用top命令或者ps命令,但是如果要查看线程怎么查看?其实也可以使用这两个命令,所以本博... 查看详情
linux常用命令(代码片段)
...grep|awk‘print$2’ps-ef|grepYarnChild|awk‘print$2’|xargskill-9然后查看该进程的CPU:top-p[PID]查看这个进程的各个线程的CPU:top-H-p[PID]CPU,内存 查看详情
linux常用命令备忘录(代码片段)
使用root登录使用last-x可查看用户登录历史:last-x使用history可以查看历史命令:history一个进程的线程数:pshHp<pid>|wc-l 查看详情
linux常用命令总结
... 指令--help:求助并获得当前指令的信息说明 查看进程: ps命令查看进程信息,top命令动态查看进程信息。 杀死运行的软件和进程:Kill-9进程号2 查看系统2.1系统 uname命令: [[email protected]~]$uname... 查看详情
linux常用的几个命令
...ind/-namefilename.txt根据名称查找/目录下的filename.txt文件。2.查看一个程序是否运行ps–ef|greptomcat查看所有有关tomcat的进程3.终止线程kill-919979终止线程号位19979的线程4.查看文件,包含隐藏文件ls-al5.当前工作目录pwd6.复制文件包括... 查看详情
2021-10-29查看cpu信息的常用命令
参考技术A一、查看CPU信息的常用命令总核数=物理CPU个数X每颗物理CPU的核数总逻辑CPU数=物理CPU个数X每颗物理CPU的核数X超线程数1、查看CPU信息(型号):cat/proc/cpuinfo|grepname|sort|uniq2、查看物理CPU总个数cat/proc/cpuinfo|grep"physicalid... 查看详情
linux常用命令
Linux常用命令查看帮助文档目录操作 1.查看当前目录路径pwd 2.目录查看ls 3.目录切换cd 4.创建目录mkdir 5.删除目录或文件rm(remove的缩写) 6.修改目录mv(move的缩写)和cp(copy的缩写)文件操作 1.新建文件touch 2... 查看详情
linux查看磁盘占用常用的两个命令
1、查看总容量、已使用、未使用容量:df-hl2、查看当前路径下,每个文件/夹占用空间大小:du-sh* 查看详情
linux常用查看日志的命令
1.查看日志常用命令 tail: -n 是显示行号;相当于nl命令;例子如下: tail-100ftest.log 实时监控100行日志   查看详情
查看linux系统架构类型的5条常用命令
导读很多时候我们都需要查看当前Linux系统是32位还是64位系统架构类型,本文中我将向大家推荐5条常用命令。无论你使用的是桌面版或是只装了文本界面的Linux环境,以下命令几乎可以通吃所有Linux发行版,例如:RHEL、CentOS、Fed... 查看详情
linux常用开发命令(代码片段)
文章目录Linux常用开发命令查看文件内容的某几行cat专项读取标准输入的数据,并将其内容输出成文件性能分析工具Top软件管理命令进程管理IO重定向查看文件大小和文件夹大小查找grep从一个输出或文件中查找指定内容别名... 查看详情
linux常用命令合集
文件和目录操作命令查看文件及内容处理命令文件压缩及解压命令信息显示命令搜索文件命令用户管理命令基础网络命令深入网络操作命令有关磁盘与文件系统的命令系统权限及用户授权相关命令查看系统用户登陆信息的命令内... 查看详情
linux与shell1.linux常用的命令(代码片段)
Linux与Shell1.Linux常用的命令文件查看目录下的内容简单查看目录下的内容详细查看目录下的内容以菜单(树)形式查看目录内容文件/目录的权限权限的更改路径方面的命令切换路径查看当前所在的目录位置目录(文件)的创... 查看详情
linux常用命令-帮助命令
...:man[命令或配置文件]功能描述:获得帮助信息例:manls查看ls命令的帮助信息;manservices查看配置文件services的帮助信息,查看配置文件的帮助不需要写配置文件的绝对路径帮助文档说明:1表示命令的帮助;5表示配置文件的帮助... 查看详情
linux查看日志常用命令
1.查看日志常用命令 tail: -n 是显示行号;相当于nl命令;例子如下: tail-100ftest.log 实时监控100行日志 tail -n 10 test.log 查询日志尾部最后10行的日志; tail-n+10test.log 查询10... 查看详情
linux常用命令(代码片段)
...行)用户所有组,用户所在的组,其他用户组查看进程的指令ps-aux查看端口的netstat-ano|findstr8080查看内存/CPU利用率top查看ip地址hostname-i/ipaddr/ipconfig查看磁盘利用率df创建文件touch查看日志gitlog从已经提交 查看详情