misc whitespace cleanup and don't poll nice on Linux
This commit is contained in:
parent
835060d157
commit
6192ccbb30
|
@ -94,6 +94,22 @@ sub new {
|
|||
};
|
||||
bless $self;
|
||||
|
||||
# Proc::ProcessTable does not return a nice value for Linux
|
||||
if ($^O =~ /linux/){
|
||||
$self->{fields}=[
|
||||
'pid',
|
||||
'uid',
|
||||
'pctcpu',
|
||||
'pctmem',
|
||||
'size',
|
||||
'rss',
|
||||
'info',
|
||||
'start',
|
||||
'time',
|
||||
'proc',
|
||||
];
|
||||
}
|
||||
|
||||
if ($^O =~ /bsd/){
|
||||
$self->{physmem}=`/sbin/sysctl -a hw.physmem`;
|
||||
chomp($self->{physmem});
|
||||
|
@ -148,7 +164,7 @@ sub colorize{
|
|||
}else{
|
||||
$field=$field.ucfirst($fields->[$fieldInt]);
|
||||
}
|
||||
|
||||
|
||||
push( @header, $field.color('reset') );
|
||||
|
||||
$fieldInt++;
|
||||
|
@ -162,16 +178,16 @@ sub colorize{
|
|||
|
||||
#an array of procs
|
||||
my @procs;
|
||||
|
||||
|
||||
#goes through it all and gathers the information
|
||||
foreach my $proc ( @{$pt->table} ){
|
||||
|
||||
|
||||
#process the requested fields
|
||||
$fieldInt=0;
|
||||
my %values;
|
||||
while ( defined( $fields->[$fieldInt] ) ){
|
||||
my $field=$fields->[$fieldInt];
|
||||
|
||||
|
||||
if (
|
||||
($^O =~ /bsd/) &&
|
||||
( $field =~ /pctmem/ )
|
||||
|
@ -260,12 +276,12 @@ sub colorize{
|
|||
if ( hex($proc->flags) & 0x00800 ){$values{traced_by_debugger}=1; }
|
||||
if ( hex($proc->flags) & 0x00001 ){$values{posix_advisory_lock}=1; }
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$values{$field}=$proc->$field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$fieldInt++;
|
||||
}
|
||||
|
||||
|
@ -279,7 +295,7 @@ sub colorize{
|
|||
if ( ! defined( $values{size} ) ){
|
||||
$values{size} = 0;
|
||||
}
|
||||
|
||||
|
||||
$values{pctmem}=sprintf('%.2f', $values{pctmem});
|
||||
$values{pctcpu}=sprintf('%.2f', $values{pctcpu});
|
||||
|
||||
|
@ -356,12 +372,11 @@ sub colorize{
|
|||
if ( $to_match eq $user ){
|
||||
$hits++;
|
||||
$matched=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$user_search_int++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#check to see if it needs to search for wait channels
|
||||
|
@ -392,12 +407,12 @@ sub colorize{
|
|||
if ( $to_match eq $proc->{wchan} ){
|
||||
$hits++;
|
||||
$matched=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$wait_search_int++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#check to see if it needs to search for CPU time usage
|
||||
|
@ -465,10 +480,8 @@ sub colorize{
|
|||
$matched++;
|
||||
}
|
||||
}
|
||||
|
||||
$time_search_int++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#check to see if it needs to search for CPU percent
|
||||
|
@ -698,9 +711,9 @@ sub colorize{
|
|||
}elsif(
|
||||
$left eq 'run'
|
||||
){
|
||||
$left='R';
|
||||
$left='R';
|
||||
}
|
||||
|
||||
|
||||
#checks if it is swapped out
|
||||
if (
|
||||
( $proc->{state} ne 'zombie' ) &&
|
||||
|
@ -708,15 +721,15 @@ sub colorize{
|
|||
){
|
||||
$left=$left.'O';
|
||||
}
|
||||
|
||||
|
||||
#waiting to exit
|
||||
if (
|
||||
( defined( $proc->{working_on_exiting} ) ) &&
|
||||
$proc->{working_on_exiting}
|
||||
){
|
||||
$left=$left.'E';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#session leader
|
||||
if (
|
||||
( defined( $proc->{is_session_leader} ) ) &&
|
||||
|
@ -724,7 +737,7 @@ sub colorize{
|
|||
){
|
||||
$left=$left.'s';
|
||||
}
|
||||
|
||||
|
||||
#checks to see if any sort of locks are present
|
||||
if (
|
||||
( defined( $proc->{is_locked} ) || defined( $proc->{posix_advisory_lock} ) )&&
|
||||
|
@ -732,7 +745,7 @@ sub colorize{
|
|||
){
|
||||
$left=$left.'L';
|
||||
}
|
||||
|
||||
|
||||
#checks to see if has a controlling terminal
|
||||
if (
|
||||
( defined( $proc->{has_controlling_terminal} ) ) &&
|
||||
|
@ -748,7 +761,7 @@ sub colorize{
|
|||
){
|
||||
$left=$left.'F';
|
||||
}
|
||||
|
||||
|
||||
#checks if it knows it is being traced
|
||||
if (
|
||||
( defined( $proc->{traced_by_debugger} ) ) &&
|
||||
|
@ -756,9 +769,9 @@ sub colorize{
|
|||
){
|
||||
$left=$left.'X';
|
||||
}
|
||||
|
||||
|
||||
$item=color($self->nextColor).$left.' '.color($self->nextColor).$proc->{wchan};
|
||||
|
||||
|
||||
}else{
|
||||
$item=color($self->nextColor).$item;
|
||||
}
|
||||
|
@ -766,9 +779,9 @@ sub colorize{
|
|||
push( @line, $item.color('reset') );
|
||||
}else{
|
||||
push( @proc_column, $item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
push( @colored, \@line );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue