Fix #1438
This commit is contained in:
parent
db50bade74
commit
56707e2473
|
@ -33,7 +33,8 @@ my %state_map = (
|
||||||
T => 'stopped',
|
T => 'stopped',
|
||||||
S => 'InterruptibleSleep',
|
S => 'InterruptibleSleep',
|
||||||
R => 'running',
|
R => 'running',
|
||||||
D => 'UninterrupibleSleep'
|
D => 'UninterrupibleSleep',
|
||||||
|
I => 'IdleKernelThread',
|
||||||
);
|
);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
|
@ -42,8 +43,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
|
||||||
"hostname:s" => { name => 'hostname' },
|
"hostname:s" => { name => 'hostname' },
|
||||||
"remote" => { name => 'remote' },
|
"remote" => { name => 'remote' },
|
||||||
"ssh-option:s@" => { name => 'ssh_option' },
|
"ssh-option:s@" => { name => 'ssh_option' },
|
||||||
|
@ -53,7 +53,7 @@ sub new {
|
||||||
"sudo" => { name => 'sudo' },
|
"sudo" => { name => 'sudo' },
|
||||||
"command:s" => { name => 'command', default => 'ps' },
|
"command:s" => { name => 'command', default => 'ps' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-options:s" => { name => 'command_options', default => '-e -o etime,pid,ppid,state,comm,args -w 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '-e -o state -o ===%t===%p===%P=== -o comm:50 -o ===%a -w 2>&1' },
|
||||||
"warning:s" => { name => 'warning' },
|
"warning:s" => { name => 'warning' },
|
||||||
"critical:s" => { name => 'critical' },
|
"critical:s" => { name => 'critical' },
|
||||||
"warning-time:s" => { name => 'warning_time' },
|
"warning-time:s" => { name => 'warning_time' },
|
||||||
|
@ -63,6 +63,7 @@ sub new {
|
||||||
"filter-state:s" => { name => 'filter_state' },
|
"filter-state:s" => { name => 'filter_state' },
|
||||||
"filter-ppid:s" => { name => 'filter_ppid' },
|
"filter-ppid:s" => { name => 'filter_ppid' },
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{result} = {};
|
$self->{result} = {};
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +71,7 @@ sub new {
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
$self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
|
@ -98,22 +100,18 @@ sub parse_output {
|
||||||
command_path => $self->{option_results}->{command_path},
|
command_path => $self->{option_results}->{command_path},
|
||||||
command_options => $self->{option_results}->{command_options});
|
command_options => $self->{option_results}->{command_options});
|
||||||
my @lines = split /\n/, $stdout;
|
my @lines = split /\n/, $stdout;
|
||||||
# Header to manage output
|
|
||||||
# ELAPSED PID PPID S COMMAND COMMAND
|
|
||||||
my $line = shift @lines;
|
my $line = shift @lines;
|
||||||
$line =~ /^(\s*?\S+\s*?\S+\s*?\S+\s*?\S+\s*?)(\S+\s*?)\S+/;
|
|
||||||
my ($pos1, $pos2) = (length($1), length($1) + length($2));
|
|
||||||
foreach my $line (@lines) {
|
foreach my $line (@lines) {
|
||||||
$line =~ /^(\s*?\S+\s*?)(\S+\s*?)(\S+\s*?)(\S+\s*?)/;
|
next if ($line !~ /^(.*?)===(.*?)===(.*?)===(.*?)===(.*?)===(.*)$/);
|
||||||
my ($elapsed, $pid, $ppid, $state) = ($1, $2, $3, $4);
|
my ($state, $elapsed, $pid, $ppid, $cmd, $args) = ($1, $2, $3, $4, $5, $6);
|
||||||
my $cmd = substr($line, $pos1, $pos2 - $pos1);
|
|
||||||
my $args = substr($line, $pos2);
|
|
||||||
|
|
||||||
$self->{result}->{centreon::plugins::misc::trim($pid)} = {ppid => centreon::plugins::misc::trim($ppid),
|
$self->{result}->{centreon::plugins::misc::trim($pid)} = {
|
||||||
|
ppid => centreon::plugins::misc::trim($ppid),
|
||||||
state => centreon::plugins::misc::trim($state),
|
state => centreon::plugins::misc::trim($state),
|
||||||
elapsed => centreon::plugins::misc::trim($elapsed),
|
elapsed => centreon::plugins::misc::trim($elapsed),
|
||||||
cmd => centreon::plugins::misc::trim($cmd),
|
cmd => centreon::plugins::misc::trim($cmd),
|
||||||
args => centreon::plugins::misc::trim($args)};
|
args => centreon::plugins::misc::trim($args)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +226,7 @@ Command path (Default: none).
|
||||||
|
|
||||||
=item B<--command-options>
|
=item B<--command-options>
|
||||||
|
|
||||||
Command options (Default: '-e -o etime,pid,ppid,state,comm,args -w 2>&1').
|
Command options (Default: '-e -o state -o ===%t===%p===%P=== -o comm:50 -o ===%a -w 2>&1').
|
||||||
|
|
||||||
=item B<--warning>
|
=item B<--warning>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue