Merge pull request #667 from Sims24/process-local-enhancement

Process local enhancement
This commit is contained in:
qgarnier 2017-05-11 22:37:42 +02:00 committed by GitHub
commit 612d4d2a1e
1 changed files with 10 additions and 3 deletions

View File

@ -31,7 +31,7 @@ my %state_map = (
X => 'dead', X => 'dead',
W => 'paging', W => 'paging',
T => 'stopped', T => 'stopped',
S => 'InterrupibleSleep', S => 'InterruptibleSleep',
R => 'running', R => 'running',
D => 'UninterrupibleSleep' D => 'UninterrupibleSleep'
); );
@ -61,6 +61,7 @@ sub new {
"filter-command:s" => { name => 'filter_command' }, "filter-command:s" => { name => 'filter_command' },
"filter-arg:s" => { name => 'filter_arg' }, "filter-arg:s" => { name => 'filter_arg' },
"filter-state:s" => { name => 'filter_state' }, "filter-state:s" => { name => 'filter_state' },
"filter-ppid:s" => { name => 'filter_ppid' },
}); });
$self->{result} = {}; $self->{result} = {};
return $self; return $self;
@ -154,7 +155,9 @@ sub run {
$self->{result}->{$pid}->{args} !~ /$self->{option_results}->{filter_arg}/); $self->{result}->{$pid}->{args} !~ /$self->{option_results}->{filter_arg}/);
next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' && next if (defined($self->{option_results}->{filter_state}) && $self->{option_results}->{filter_state} ne '' &&
$state_map{$self->{result}->{$pid}->{state}} !~ /$self->{option_results}->{filter_state}/i); $state_map{$self->{result}->{$pid}->{state}} !~ /$self->{option_results}->{filter_state}/i);
next if (defined($self->{option_results}->{filter_ppid}) && $self->{option_results}->{filter_ppid} ne '' &&
$self->{result}->{$pid}->{ppid} !~ /$self->{option_results}->{filter_ppid}/);
$self->{output}->output_add(long_msg => 'Process: [command => ' . $self->{result}->{$pid}->{cmd} . $self->{output}->output_add(long_msg => 'Process: [command => ' . $self->{result}->{$pid}->{cmd} .
'] [arg => ' . $self->{result}->{$pid}->{args} . '] [arg => ' . $self->{result}->{$pid}->{args} .
'] [state => ' . $state_map{$self->{result}->{$pid}->{state}} . ']'); '] [state => ' . $state_map{$self->{result}->{$pid}->{state}} . ']');
@ -253,6 +256,10 @@ Filter process commands (regexp can be used).
Filter process arguments (regexp can be used). Filter process arguments (regexp can be used).
=item B<--filter-ppid>
Filter process ppid (regexp can be used).
=item B<--filter-state> =item B<--filter-state>
Filter process states (regexp can be used). Filter process states (regexp can be used).
@ -261,4 +268,4 @@ You can use: 'zombie', 'dead', 'paging', 'stopped',
=back =back
=cut =cut