diff --git a/Proc-ProcessTable-ncps/bin/ncps b/Proc-ProcessTable-ncps/bin/ncps index 444a7ea..7bd4605 100755 --- a/Proc-ProcessTable-ncps/bin/ncps +++ b/Proc-ProcessTable-ncps/bin/ncps @@ -24,13 +24,62 @@ sub help{ -m A numeric search for memory usage percent -w A string search for wait channels. - +--wi '; } +# defaults +my $wait_channels_string; +my $wait_channels_invert=0; +my $version; +my $help; + +# get the commandline options +Getopt::Long::Configure ('no_ignore_case'); +Getopt::Long::Configure ('bundling'); +GetOptions( + 'w=s' => \$wait_channels_string, + 'wi' => \$wait_channels_invert, + 'h' => \$help, + 'help' => \$help, + 'v' => \$version, + 'version' => \$version, + ); + +# print the version info if requested +if ( $version ){ + &version; + exit; +} + +if ( $help ){ + &version; + &help; + exit; +} + +my @filters; + +# +# handles wait channels +# +if ( defined( $wait_channels_string ) ){ + my @wchans=split(/\,/, $wait_channels_string ); + push( @filters, { + type=>'WChan', + invert=>$wait_channels_invert, + args=>{ + wchans=>\@wchans, + }, + }); +} + my $args={ invert=>0, + match=>{ + checks=>\@filters, + } }; my $ncps=Proc::ProcessTable::ncps->new( $args ); diff --git a/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm b/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm index b436427..08bfa0b 100644 --- a/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm +++ b/Proc-ProcessTable-ncps/lib/Proc/ProcessTable/ncps.pm @@ -47,7 +47,11 @@ sub new { }; bless $self; - if ( defined( $args{match} ) ){ + if ( + defined( $args{match} ) && + defined( $args{match}{checks} ) && + defined( $args{match}{checks}[0] ) + ){ $self->{match}=Proc::ProcessTable::Match->new( $args{match} ); }