using pctcpu
Zane C. B-H.
v.velox at vvelox.net
Mon Nov 6 10:16:18 UTC 2017
On 2017-10-09 23:16, Zane C. B-H. wrote:
> Using https://metacpan.org/pod/BSD::Process that to get pctcpu, but I
> can't get it to line up nicely with ps.
>
> The closest I can get is dividing pctcpu by 20, but that still tends
> to run high. For example dividing by 20 will give me 1635.8 while ps
> will show 1595.3.
>
> I know the 1635.8 is definitely off as this machine only has 16 cores.
The answer to this happens to be...
my $bproc=BSD::Process::info( $proc->pid );
my $pctcpu=$bproc->{pctcpu};
if ( ! defined( $pctcpu ) ){
$values{pctcpu}=0
}else{
my $fscale=`/sbin/sysctl -a kern.fscale`;
$fscale=~s/^.*\: //;
chomp($fscale);
$values{pctcpu}= 100 * ( $pctcpu / $fscale );
}
Also Wooho! Initial release of Proc-ProcessTable-Colorizer published to
CPAN. :3
More information about the freebsd-hackers
mailing list