fix new ssh backend custom
This commit is contained in:
parent
202e924591
commit
8fead5fb3e
|
@ -83,14 +83,7 @@ sub set_defaults {
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{option_results}->{remote} = 1;
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
if (defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '') {
|
|
||||||
$self->{option_results}->{remote} = 0;
|
|
||||||
} elsif (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') {
|
|
||||||
$self->{output}->add_option_msg(short_msg => 'Need to set hostname option.');
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ($self->{option_results}->{remote} == 1) {
|
|
||||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +108,7 @@ sub execute_command {
|
||||||
$options{command} . "\n";
|
$options{command} . "\n";
|
||||||
|
|
||||||
my $stdout;
|
my $stdout;
|
||||||
if ($self->{option_results}->{remote} == 1) {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
($stdout) = $self->{ssh}->execute(
|
($stdout) = $self->{ssh}->execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
hostname => $self->{option_results}->{hostname},
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
@ -125,6 +118,10 @@ sub execute_command {
|
||||||
timeout => $self->{option_results}->{timeout}
|
timeout => $self->{option_results}->{timeout}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command for local)');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
($stdout) = centreon::plugins::misc::execute(
|
($stdout) = centreon::plugins::misc::execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
output => $self->{output},
|
output => $self->{output},
|
||||||
|
|
|
@ -82,15 +82,7 @@ sub set_defaults {
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{remote} = 1;
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
if (defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '') {
|
|
||||||
$self->{remote} = 0;
|
|
||||||
} elsif (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') {
|
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to set hostname option.");
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($self->{remote} == 1) {
|
|
||||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +103,7 @@ sub execute_command {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $content;
|
my $content;
|
||||||
if ($self->{remote} == 1) {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
($content) = $self->{ssh}->execute(
|
($content) = $self->{ssh}->execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
hostname => $self->{option_results}->{hostname},
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
@ -121,6 +113,10 @@ sub execute_command {
|
||||||
timeout => $self->{option_results}->{timeout}
|
timeout => $self->{option_results}->{timeout}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command for local)');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
($content) = centreon::plugins::misc::execute(
|
($content) = centreon::plugins::misc::execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
output => $self->{output},
|
output => $self->{output},
|
||||||
|
|
|
@ -82,14 +82,7 @@ sub set_defaults {
|
||||||
sub check_options {
|
sub check_options {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{remote} = 1;
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
if (defined($self->{option_results}->{command}) && $self->{option_results}->{command} ne '') {
|
|
||||||
$self->{remote} = 0;
|
|
||||||
} elsif (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') {
|
|
||||||
$self->{output}->add_option_msg(short_msg => 'Need to set hostname option.');
|
|
||||||
$self->{output}->option_exit();
|
|
||||||
}
|
|
||||||
if ($self->{remote} == 1) {
|
|
||||||
$self->{ssh}->check_options(option_results => $self->{option_results});
|
$self->{ssh}->check_options(option_results => $self->{option_results});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +101,7 @@ sub execute_command {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $content;
|
my $content;
|
||||||
if ($self->{remote} == 1) {
|
if (defined($self->{option_results}->{hostname}) && $self->{option_results}->{hostname} ne '') {
|
||||||
($content) = $self->{ssh}->execute(
|
($content) = $self->{ssh}->execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
hostname => $self->{option_results}->{hostname},
|
hostname => $self->{option_results}->{hostname},
|
||||||
|
@ -118,6 +111,10 @@ sub execute_command {
|
||||||
timeout => $self->{option_results}->{timeout}
|
timeout => $self->{option_results}->{timeout}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
||||||
|
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command for local)');
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
($content) = centreon::plugins::misc::execute(
|
($content) = centreon::plugins::misc::execute(
|
||||||
ssh_pipe => 1,
|
ssh_pipe => 1,
|
||||||
output => $self->{output},
|
output => $self->{output},
|
||||||
|
|
|
@ -125,7 +125,7 @@ sub execute_command {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
if (!defined($self->{option_results}->{command}) || $self->{option_results}->{command} eq '') {
|
||||||
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command)');
|
$self->{output}->add_option_msg(short_msg => 'please set --hostname option for ssh connection (or --command for local)');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
($content) = centreon::plugins::misc::execute(
|
($content) = centreon::plugins::misc::execute(
|
||||||
|
|
Loading…
Reference in New Issue