prstat in Ubuntu or Centos



正如Java Performance所说:

Solaris prstat具有额外的功能例如报告用户和内核或系统CPU利用率以及其他使用prstat -m和-L选项获取微状态信息。-m选项打印微状态信息,-L打印每个轻量级进程的统计信息。

在Centos或Ubuntu中有没有类似于prstat的工具?

我相信您正在寻找的Linux命令是toppstree

这里是ptree for Linux,

#!/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"

在Linux中没有prstat "等效"工具。您可以使用top和ps(或/proc/$pid/resources)的组合来获得一些有用的结果;也许可以编写一个shell脚本(使用grep、sed和awk)来收集上述命令和文件的结果。仅供参考,我发现这个关于顶级命令和内核,用户和空闲CPU利用率的链接很有趣

http://blog.scoutapp.com/articles/2015/02/24/understanding-linuxs-cpu-stats

希望这对你有帮助。

最新更新