From cd4526dc68bbfe7b8cccae455ea2ec99e4094ba1 Mon Sep 17 00:00:00 2001 From: "Zane C. Bowers-Hadley" Date: Thu, 22 Aug 2019 17:25:02 -0500 Subject: [PATCH] add cmin/cmaj faults --- Proc-ProcessTable-ncps/bin/ncps | 10 ++++++ .../lib/Proc/ProcessTable/ncps.pm | 34 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/Proc-ProcessTable-ncps/bin/ncps b/Proc-ProcessTable-ncps/bin/ncps index d59a2c5..2cbf8ac 100755 --- a/Proc-ProcessTable-ncps/bin/ncps +++ b/Proc-ProcessTable-ncps/bin/ncps @@ -15,6 +15,10 @@ sub help{ -c Search procs using the matching regex. --ci Invert the command search. +--cf Show children minor faults. + +--cF Show children major faults. + -m Memory usage percent to search for. --mi Invert the memory usage search. @@ -72,6 +76,8 @@ my $states_string; my $states_invert=0; my $minor_faults=0; my $major_faults=0; +my $cminor_faults=0; +my $cmajor_faults=0; # get the commandline options Getopt::Long::Configure ('no_ignore_case'); @@ -102,6 +108,8 @@ GetOptions( 'sti' => \$states_invert, 'f' => \$minor_faults, 'F' => \$major_faults, + 'cf' => \$cminor_faults, + 'cF' => \$cmajor_faults, ); # print the version info if requested @@ -243,6 +251,8 @@ if ( defined( $states_string ) ){ my $args={ invert=>0, + cmajor_faults=>$cmajor_faults, + cminor_faults=>$cminor_faults, major_faults=>$major_faults, minor_faults=>$minor_faults, match=>{ diff --git a/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm b/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm index 3609703..1f4cd8f 100644 --- a/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm +++ b/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm @@ -79,6 +79,14 @@ sub new { $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}; + } + return $self; } @@ -178,6 +186,18 @@ sub run{ if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; } $tb->set_column_style($header_int, pad => $padding ); $header_int++; } + # add children major faults if needed + if ( $self->{cmajor_faults} ){ + push( @headers, 'cMajF' ); + 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->{minor_faults} ){ + push( @headers, 'cminF' ); + 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' ); @@ -372,6 +392,20 @@ sub run{ push( @new_line, color($self->nextColor).$proc->{minflt}.color('reset') ); } + # + # children major faults + # + if ( $self->{cmajor_faults} ){ + push( @new_line, color($self->nextColor).$proc->{cmajflt}.color('reset') ); + } + + # + # children major faults + # + if ( $self->{cminor_faults} ){ + push( @new_line, color($self->nextColor).$proc->{cminflt}.color('reset') ); + } + # # handles the start column #