when the pctcpu value is at 99.9 (probed via ps -e -o
pcpu) i get an extrange value like -71.4 it only
happends with this process (99.9) other process are ok...
THIS is an example of what i get with my script
====================================== nodo19
USUARIO PID PPID %CPU
ndc 820 1094 -71.47
ndc 821 820 -71.47
here it is the output of the comando
ps -e -o user,pid,ppid,pcpu
ndc 419 1443 99.9
ndc 420 419 99.9
what is the problem? is it my sourcecode???
here it is...
#!/usr/bin/perl
use Proc::ProcessTable;
$tobj = new Proc::ProcessTable;
$proctable = $tobj->table();
@meses =
("ene","feb","mar","abr","may","jun","jul","ago","sep","oct","nov","dic");
if(scalar @ARGV < 1){
$opt = "all";
}else{
if($ARGV[0] eq "all"){
$opt = "all";
}elsif($ARGV[0] eq "-u" && scalar @ARGV > 1){
$opt = "u";
$ruser = $ARGV[1];
}else{
$opt = "root";
}
}
if($opt eq "u"){
for (@$proctable){
$user = getpwuid($_->uid);
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($_->start);
$yearr = substr($year,1);
$monr = $meses[$mon];
write() if $user eq "$ruser";
}
}else{
for (sort @$proctable){
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($_->start);
$monr = $meses[$mon];
$yearr = substr($year,1);
$user = getpwuid($_->uid);
if($opt eq "all"){
write if $user ne "root";
}else{
write if $user eq "root";
}
}
}
format =
@<<<<<<< @<<<<< @<<<<< @##.## @##.##
@<-@<<-@< @#:@# @<<<<<<<<<<<<<<<<<<<<<
$user, $_->pid, $_->ppid,
$_->pctmem,$_->pctcpu,$mday,$monr,$yearr,$hour, $min
$_->fname
.
format STDOUT_TOP =
USUARIO PID PPID %MEMORIA %CPU START
COMANDO
.