+ add possibility to filter on ppid

Ref https://github.com/centreon/centreon-plugins/issues/666 #devilissue :)
This commit is contained in:
Simon Bomm 2017-05-11 22:12:21 +02:00 committed by GitHub
parent 2ffb7aabaf
commit 18d1dd94e9
1 changed files with 8 additions and 1 deletions

View File

@ -61,6 +61,7 @@ sub new {
"filter-command:s" => { name => 'filter_command' },
"filter-arg:s" => { name => 'filter_arg' },
"filter-state:s" => { name => 'filter_state' },
"filter-ppid:s" => { name => 'filter_ppid' },
});
$self->{result} = {};
return $self;
@ -154,7 +155,9 @@ sub run {
$self->{result}->{$pid}->{args} !~ /$self->{option_results}->{filter_arg}/);
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);
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} .
'] [arg => ' . $self->{result}->{$pid}->{args} .
'] [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).
=item B<--filter-ppid>
Filter process ppid (regexp can be used).
=item B<--filter-state>
Filter process states (regexp can be used).