enhance indent
This commit is contained in:
parent
15acd61afb
commit
876ff7003d
|
@ -31,21 +31,21 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$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' },
|
'ssh-path:s' => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
'timeout:s' => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
'sudo' => { name => 'sudo' },
|
||||||
"sudo" => { name => 'sudo' },
|
'command:s' => { name => 'command' },
|
||||||
"command:s" => { name => 'command' },
|
'command-path:s' => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
'command-options:s' => { name => 'command_options' },
|
||||||
"command-options:s" => { name => 'command_options' },
|
'manage-returns:s' => { name => 'manage_returns', default => '' },
|
||||||
"manage-returns:s" => { name => 'manage_returns', default => '' },
|
'separator:s' => { name => 'separator', default => '#' },
|
||||||
"separator:s" => { name => 'separator', default => '#' },
|
});
|
||||||
});
|
|
||||||
$self->{manage_returns} = {};
|
$self->{manage_returns} = {};
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ sub check_options {
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{command})) {
|
if (!defined($self->{option_results}->{command})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify command option.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify command option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) {
|
foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) {
|
||||||
|
@ -77,31 +77,41 @@ sub check_options {
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($stdout, $exit_code) = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout, $exit_code) = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
sudo => $self->{option_results}->{sudo},
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options},
|
command_path => $self->{option_results}->{command_path},
|
||||||
no_quit => 1);
|
command_options => $self->{option_results}->{command_options},
|
||||||
|
no_quit => 1
|
||||||
|
);
|
||||||
my $long_msg = $stdout;
|
my $long_msg = $stdout;
|
||||||
$long_msg =~ s/\|/~/mg;
|
$long_msg =~ s/\|/~/mg;
|
||||||
$self->{output}->output_add(long_msg => $long_msg);
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
|
||||||
if (defined($self->{manage_returns}->{$exit_code})) {
|
if (defined($self->{manage_returns}->{$exit_code})) {
|
||||||
$self->{output}->output_add(severity => $self->{manage_returns}->{$exit_code}->{return},
|
$self->{output}->output_add(
|
||||||
short_msg => $self->{manage_returns}->{$exit_code}->{msg});
|
severity => $self->{manage_returns}->{$exit_code}->{return},
|
||||||
|
short_msg => $self->{manage_returns}->{$exit_code}->{msg}
|
||||||
|
);
|
||||||
} elsif (defined($self->{manage_returns}->{default})) {
|
} elsif (defined($self->{manage_returns}->{default})) {
|
||||||
$self->{output}->output_add(severity => $self->{manage_returns}->{default}->{return},
|
$self->{output}->output_add(
|
||||||
short_msg => $self->{manage_returns}->{default}->{msg});
|
severity => $self->{manage_returns}->{default}->{return},
|
||||||
|
short_msg => $self->{manage_returns}->{default}->{msg}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->output_add(severity => 'UNKNWON',
|
$self->{output}->output_add(
|
||||||
short_msg => 'Exit code from command');
|
severity => 'UNKNWON',
|
||||||
|
short_msg => 'Exit code from command'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($exit_code)) {
|
if (defined($exit_code)) {
|
||||||
$self->{output}->perfdata_add(label => "code",
|
$self->{output}->perfdata_add(
|
||||||
value => $exit_code);
|
label => 'code',
|
||||||
|
value => $exit_code
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
|
|
|
@ -31,21 +31,21 @@ sub new {
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$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' },
|
'ssh-path:s' => { name => 'ssh_path' },
|
||||||
"ssh-path:s" => { name => 'ssh_path' },
|
'ssh-command:s' => { name => 'ssh_command', default => 'ssh' },
|
||||||
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
|
'timeout:s' => { name => 'timeout', default => 30 },
|
||||||
"timeout:s" => { name => 'timeout', default => 30 },
|
'sudo' => { name => 'sudo' },
|
||||||
"sudo" => { name => 'sudo' },
|
'command:s' => { name => 'command' },
|
||||||
"command:s" => { name => 'command' },
|
'command-path:s' => { name => 'command_path' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
'command-options:s' => { name => 'command_options' },
|
||||||
"command-options:s" => { name => 'command_options' },
|
'manage-returns:s' => { name => 'manage_returns', default => '' },
|
||||||
"manage-returns:s" => { name => 'manage_returns', default => '' },
|
'separator:s' => { name => 'separator', default => '#' },
|
||||||
"separator:s" => { name => 'separator', default => '#' },
|
});
|
||||||
});
|
|
||||||
$self->{manage_returns} = {};
|
$self->{manage_returns} = {};
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ sub check_options {
|
||||||
$self->SUPER::init(%options);
|
$self->SUPER::init(%options);
|
||||||
|
|
||||||
if (!defined($self->{option_results}->{command})) {
|
if (!defined($self->{option_results}->{command})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Need to specify command option.");
|
$self->{output}->add_option_msg(short_msg => "Need to specify command option.");
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) {
|
foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) {
|
||||||
|
@ -77,31 +77,41 @@ sub check_options {
|
||||||
sub run {
|
sub run {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($stdout, $exit_code) = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout, $exit_code) = centreon::plugins::misc::execute(
|
||||||
options => $self->{option_results},
|
output => $self->{output},
|
||||||
sudo => $self->{option_results}->{sudo},
|
options => $self->{option_results},
|
||||||
command => $self->{option_results}->{command},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command_path => $self->{option_results}->{command_path},
|
command => $self->{option_results}->{command},
|
||||||
command_options => $self->{option_results}->{command_options},
|
command_path => $self->{option_results}->{command_path},
|
||||||
no_quit => 1);
|
command_options => $self->{option_results}->{command_options},
|
||||||
|
no_quit => 1
|
||||||
|
);
|
||||||
my $long_msg = $stdout;
|
my $long_msg = $stdout;
|
||||||
$long_msg =~ s/\|/~/mg;
|
$long_msg =~ s/\|/~/mg;
|
||||||
$self->{output}->output_add(long_msg => $long_msg);
|
$self->{output}->output_add(long_msg => $long_msg);
|
||||||
|
|
||||||
if (defined($self->{manage_returns}->{$exit_code})) {
|
if (defined($self->{manage_returns}->{$exit_code})) {
|
||||||
$self->{output}->output_add(severity => $self->{manage_returns}->{$exit_code}->{return},
|
$self->{output}->output_add(
|
||||||
short_msg => $self->{manage_returns}->{$exit_code}->{msg});
|
severity => $self->{manage_returns}->{$exit_code}->{return},
|
||||||
|
short_msg => $self->{manage_returns}->{$exit_code}->{msg}
|
||||||
|
);
|
||||||
} elsif (defined($self->{manage_returns}->{default})) {
|
} elsif (defined($self->{manage_returns}->{default})) {
|
||||||
$self->{output}->output_add(severity => $self->{manage_returns}->{default}->{return},
|
$self->{output}->output_add(
|
||||||
short_msg => $self->{manage_returns}->{default}->{msg});
|
severity => $self->{manage_returns}->{default}->{return},
|
||||||
|
short_msg => $self->{manage_returns}->{default}->{msg}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$self->{output}->output_add(severity => 'UNKNWON',
|
$self->{output}->output_add(
|
||||||
short_msg => 'Exit code from command');
|
severity => 'UNKNWON',
|
||||||
|
short_msg => 'Exit code from command'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined($exit_code)) {
|
if (defined($exit_code)) {
|
||||||
$self->{output}->perfdata_add(label => "code",
|
$self->{output}->perfdata_add(
|
||||||
value => $exit_code);
|
label => 'code',
|
||||||
|
value => $exit_code
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
|
|
Loading…
Reference in New Issue