Browse Source

add display for minor and major faults

master
Zane C. B-H 2 years ago
parent
commit
00126c41e7
  1. 10
      Proc-ProcessTable-ncps/bin/ncps
  2. 40
      Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm

10
Proc-ProcessTable-ncps/bin/ncps

@ -18,6 +18,10 @@ sub help{
-m <pctmem> Memory usage percent to search for.
--mi Invert the memory usage search.
-f Show minor faults.
-F Show major faults.
-p <pctcpu> CPU usage percent to search for.
--pi Invert the CPU usage search.
@ -66,6 +70,8 @@ my $time_string;
my $time_invert=0;
my $states_string;
my $states_invert=0;
my $minor_faults=0;
my $major_faults=0;
# get the commandline options
Getopt::Long::Configure ('no_ignore_case');
@ -94,6 +100,8 @@ GetOptions(
'ti' => \$time_invert,
'st=s' => \$states_string,
'sti' => \$states_invert,
'f' => \$minor_faults,
'F' => \$major_faults,
);
# print the version info if requested
@ -235,6 +243,8 @@ if ( defined( $states_string ) ){
my $args={
invert=>0,
major_faults=>$major_faults,
minor_faults=>$minor_faults,
match=>{
checks=>\@filters,
}

40
Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm

@ -44,6 +44,8 @@ sub new {
my $self = {
invert=>0,
match=>undef,
minor_faults=>0,
major_faults=>0,
colors=>[
'BRIGHT_YELLOW',
'BRIGHT_CYAN',
@ -69,6 +71,14 @@ sub new {
$self->{match}=Proc::ProcessTable::Match->new( $args{match} );
}
if ( defined( $args{major_faults} ) ){
$self->{major_faults}=$args{major_faults};
}
if ( defined( $args{minor_faults} ) ){
$self->{minor_faults}=$args{minor_faults};
}
return $self;
}
@ -144,18 +154,30 @@ sub run{
push( @headers, 'RSS' );
$tb->set_column_style($header_int, pad => 0); $header_int++;
push( @headers, 'Info' );
# add
# add nice if needed
if ( $have_nice ){
push( @headers, 'Nic' );
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
# add
# add priority if needed
if ( $have_pri ){
push( @headers, 'Pri' );
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
# add major faults if needed
if ( $self->{major_faults} ){
push( @headers, 'MajF' );
if (( $header_int % 2 ) != 0){ $padding=1; }else{ $padding=0; }
$tb->set_column_style($header_int, pad => $padding ); $header_int++;
}
# add minor faults if needed
if ( $self->{minor_faults} ){
push( @headers, 'minF' );
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' );
@ -336,6 +358,20 @@ sub run{
push( @new_line, color($self->nextColor).$proc->{priority}.color('reset') );
}
#
# major faults
#
if ( $self->{major_faults} ){
push( @new_line, color($self->nextColor).$proc->{majflt}.color('reset') );
}
#
# major faults
#
if ( $self->{minor_faults} ){
push( @new_line, color($self->nextColor).$proc->{minflt}.color('reset') );
}
#
# handles the start column
#

Loading…
Cancel
Save