加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 在Ubuntu或Centos中的prstat

发布时间:2020-12-13 22:58:16 所属栏目:Linux 来源:网络整理
导读:正如 Java Performance所说: Solaris prstat has additional capabilities such as reporting both user and kernel or system CPU utilization along with other microstate information using the prstat -m and -L options. The -m option prints micros
正如 Java Performance所说:

Solaris prstat has additional capabilities
such as reporting both user and kernel or system CPU utilization along with other
microstate information using the prstat -m and -L options. The -m option prints
microstate information,and -L prints statistics on per lightweight process.

在Centos或Ubuntu中有没有像prstat这样的工具?

解决方法

我相信你正在寻找的 Linux命令是top和pstree.

这是Linux的ptree,

#!/bin/sh
# Solaris style ptree

[ -x /usr/bin/ptree ] && exec /usr/bin/ptree "$@"

# Print process tree
# $1 = PID : extract tree for this process
# $1 = user : filter for this (existing) user
# $1 = user $2 = PID : do both

PATH=/bin:/usr/bin:/usr/sbin:/sbin
export PATH

psopt="-e"
case $1 in
[a-z]*) psopt="-u $1";shift;;
esac

[ -z "$1" ] &&
exec ps $psopt -Ho pid=,args=

#some effort to add less to the ps list
tmp=/tmp/ptree.$$
trap 'rm $tmp' 0 HUP INT TERM
ps $psopt -Ho pid=,args= >$tmp
<$tmp awk '
{ ci=index(substr($0,7),$2); o[ci]=$0 }
ci>s[a] { s[++a]=ci }
$1==pid {
    for(i=1;i<=a;i++) {
            si=s[i]; if(si<=ci) print o[si]
    }
    walkdown=ci
            next
}
ci<walkdown { exit }
walkdown!=0 { print }
' pid="$1"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读