cleanup realing in booleans and add tty support

This commit is contained in:
Zane C. B-H 2019-08-22 17:45:44 -05:00
parent a55e685a32
commit a3e3392454
2 changed files with 23 additions and 18 deletions

View File

@ -46,6 +46,8 @@ sub help{
-t <times> A comma seperated value of time, in seconds, to search for.
--ti Invert the time search.
--tty Show TTYs.
-w <wchans> A string search for wait channels.
--wi Invert the wait channel search.
@ -81,6 +83,7 @@ my $major_faults=0;
my $cminor_faults=0;
my $cmajor_faults=0;
my $numthr=0;
my $tty=0,
# get the commandline options
Getopt::Long::Configure ('no_ignore_case');
@ -114,6 +117,7 @@ GetOptions(
'cf' => \$cminor_faults,
'cF' => \$cmajor_faults,
'n' => \$numthr,
'tty' => \$tty,
);
# print the version info if requested
@ -260,6 +264,7 @@ my $args={
major_faults=>$major_faults,
minor_faults=>$minor_faults,
numthr=>$numthr,
tty=>$tty,
match=>{
checks=>\@filters,
}

View File

@ -71,24 +71,11 @@ sub new {
$self->{match}=Proc::ProcessTable::Match->new( $args{match} );
}
if ( defined( $args{major_faults} ) ){
$self->{major_faults}=$args{major_faults};
}
my @bool_feed=('major_faults', 'minor_faults', 'cmajor_faults',
'cminor_faults', 'numthr', 'tty');
if ( defined( $args{minor_faults} ) ){
$self->{minor_faults}=$args{minor_faults};
}
if ( defined( $args{cmajor_faults} ) ){
$self->{cmajor_faults}=$args{cmajor_faults};
}
if ( defined( $args{cminor_faults} ) ){
$self->{cminor_faults}=$args{cminor_faults};
}
if ( defined( $args{numthr} ) ){
$self->{numthr}=$args{numthr};
foreach my $feed ( @bool_feed ){
$self->{$feed}=$args{$feed};
}
return $self;
@ -197,7 +184,7 @@ sub run{
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
# add children minor faults if needed
if ( $self->{minor_faults} ){
if ( $self->{cminor_faults} ){
push( @headers, 'cminF' );
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
@ -208,6 +195,12 @@ sub run{
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
# add children minor faults if needed
if ( $self->{tty} ){
push( @headers, 'TTY' );
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
push( @headers, 'Start' );
@ -423,6 +416,13 @@ sub run{
push( @new_line, color($self->nextColor).$proc->{numthr}.color('reset') );
}
#
# number of threads
#
if ( $self->{tty} ){
push( @new_line, color($self->nextColor).$proc->{ttydev}.color('reset') );
}
#
# handles the start column
#