+ Fix netbackup plugin
This commit is contained in:
parent
24e67d56a4
commit
0e4fbd5ac4
|
@ -112,7 +112,7 @@ sub new {
|
||||||
"sudo" => { name => 'sudo' },
|
"sudo" => { name => 'sudo' },
|
||||||
"command:s" => { name => 'command', default => 'nbdevquery' },
|
"command:s" => { name => 'command', default => 'nbdevquery' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-options:s" => { name => 'command_options', default => '-listdv -U -stype PureDisk 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '-listdv -U -stype PureDisk' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
|
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
|
||||||
|
@ -148,7 +148,7 @@ sub change_macros {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
|
@ -238,7 +238,7 @@ Command path (Default: none).
|
||||||
|
|
||||||
=item B<--command-options>
|
=item B<--command-options>
|
||||||
|
|
||||||
Command options (Default: '-listdv -U -stype PureDisk 2>&1').
|
Command options (Default: '-listdv -U -stype PureDisk').
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ sub new {
|
||||||
"sudo" => { name => 'sudo' },
|
"sudo" => { name => 'sudo' },
|
||||||
"command:s" => { name => 'command', default => 'tpconfig' },
|
"command:s" => { name => 'command', default => 'tpconfig' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-options:s" => { name => 'command_options', default => '-l 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '-l' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ sub new {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
|
@ -158,7 +158,7 @@ Command path (Default: none).
|
||||||
|
|
||||||
=item B<--command-options>
|
=item B<--command-options>
|
||||||
|
|
||||||
Command options (Default: '-l 2>&1').
|
Command options (Default: '-l').
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ sub new {
|
||||||
"sudo" => { name => 'sudo' },
|
"sudo" => { name => 'sudo' },
|
||||||
"command:s" => { name => 'command', default => 'tpconfig' },
|
"command:s" => { name => 'command', default => 'tpconfig' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-options:s" => { name => 'command_options', default => '-l 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '-l' },
|
||||||
"filter-name:s" => { name => 'filter_name' },
|
"filter-name:s" => { name => 'filter_name' },
|
||||||
"warning-status:s" => { name => 'warning_status', default => '' },
|
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||||
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
|
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
|
||||||
|
@ -139,7 +139,7 @@ sub change_macros {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
|
@ -218,7 +218,7 @@ Command path (Default: none).
|
||||||
|
|
||||||
=item B<--command-options>
|
=item B<--command-options>
|
||||||
|
|
||||||
Command options (Default: '-l 2>&1').
|
Command options (Default: '-l').
|
||||||
|
|
||||||
=item B<--filter-name>
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ sub new {
|
||||||
"sudo" => { name => 'sudo' },
|
"sudo" => { name => 'sudo' },
|
||||||
"command:s" => { name => 'command', default => 'bpdbjobs' },
|
"command:s" => { name => 'command', default => 'bpdbjobs' },
|
||||||
"command-path:s" => { name => 'command_path' },
|
"command-path:s" => { name => 'command_path' },
|
||||||
"command-options:s" => { name => 'command_options', default => '-report -most_columns 2>&1' },
|
"command-options:s" => { name => 'command_options', default => '-report -most_columns' },
|
||||||
"filter-policy-name:s" => { name => 'filter_policy_name' },
|
"filter-policy-name:s" => { name => 'filter_policy_name' },
|
||||||
"filter-end-time:s" => { name => 'filter_end_time', default => 86400 },
|
"filter-end-time:s" => { name => 'filter_end_time', default => 86400 },
|
||||||
"ok-status:s" => { name => 'ok_status', default => '%{status} == 0' },
|
"ok-status:s" => { name => 'ok_status', default => '%{status} == 0' },
|
||||||
|
@ -285,7 +285,7 @@ sub manage_selection {
|
||||||
$self->{cache_name} = "netbackup_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{sudo} : 'me') . '_' .
|
$self->{cache_name} = "netbackup_" . $self->{mode} . '_' . (defined($self->{option_results}->{hostname}) ? $self->{option_results}->{sudo} : 'me') . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
|
@ -298,7 +298,7 @@ sub manage_selection {
|
||||||
my ($job_id, $job_type, $job_state, $job_status, $job_pname, $job_start_time, $job_end_time, $job_kb) =
|
my ($job_id, $job_type, $job_state, $job_status, $job_pname, $job_start_time, $job_end_time, $job_kb) =
|
||||||
($values[0], $values[1], $values[2], $values[3], $values[4], $values[8], $values[10], $values[14]);
|
($values[0], $values[1], $values[2], $values[3], $values[4], $values[8], $values[10], $values[14]);
|
||||||
|
|
||||||
my $display = $job_pname . '/' . $job_id;
|
my $display = (defined($job_pname) ? $job_pname : '-') . '/' . $job_id;
|
||||||
if (defined($self->{option_results}->{filter_policy_name}) && $self->{option_results}->{filter_policy_name} ne '' &&
|
if (defined($self->{option_results}->{filter_policy_name}) && $self->{option_results}->{filter_policy_name} ne '' &&
|
||||||
$job_pname !~ /$self->{option_results}->{filter_policy_name}/) {
|
$job_pname !~ /$self->{option_results}->{filter_policy_name}/) {
|
||||||
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
|
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
|
||||||
|
@ -313,7 +313,7 @@ sub manage_selection {
|
||||||
my $elapsed_time = $current_time - $job_start_time;
|
my $elapsed_time = $current_time - $job_start_time;
|
||||||
$self->{job}->{$display} = { display => $display, elapsed => $elapsed_time,
|
$self->{job}->{$display} = { display => $display, elapsed => $elapsed_time,
|
||||||
status => $job_status, state => $job_state{$job_state}, type => $job_type{$job_type},
|
status => $job_status, state => $job_state{$job_state}, type => $job_type{$job_type},
|
||||||
kb => $job_kb };
|
kb => defined($job_kb) && $job_kb =~ /[0-9]+/ ? $job_kb : undef };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scalar(keys %{$self->{job}}) <= 0) {
|
if (scalar(keys %{$self->{job}}) <= 0) {
|
||||||
|
@ -371,7 +371,7 @@ Command path (Default: none).
|
||||||
|
|
||||||
=item B<--command-options>
|
=item B<--command-options>
|
||||||
|
|
||||||
Command options (Default: '-report -most_columns 2>&1').
|
Command options (Default: '-report -most_columns').
|
||||||
|
|
||||||
=item B<--filter-policy-name>
|
=item B<--filter-policy-name>
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ sub disco_show {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $self->{option_results}->{command},
|
command => $self->{option_results}->{command},
|
||||||
|
@ -111,7 +111,7 @@ sub manage_selection {
|
||||||
foreach my $policy_name (@lines) {
|
foreach my $policy_name (@lines) {
|
||||||
my $command2 = $self->{option_results}->{command2};
|
my $command2 = $self->{option_results}->{command2};
|
||||||
$command2 =~ s/%{policy_name}/$policy_name/g;
|
$command2 =~ s/%{policy_name}/$policy_name/g;
|
||||||
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
|
my ($stdout2) = centreon::plugins::misc::execute(output => $self->{output},
|
||||||
options => $self->{option_results},
|
options => $self->{option_results},
|
||||||
sudo => $self->{option_results}->{sudo},
|
sudo => $self->{option_results}->{sudo},
|
||||||
command => $command2);
|
command => $command2);
|
||||||
|
|
|
@ -24,6 +24,16 @@ use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use utf8;
|
use utf8;
|
||||||
|
|
||||||
|
sub execute {
|
||||||
|
my (%options) = @_;
|
||||||
|
|
||||||
|
if ($^O eq 'MSWin32') {
|
||||||
|
return windows_execute(%options, timeout => $options{options}->{timeout});
|
||||||
|
} else {
|
||||||
|
return unix_execute(%options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub windows_execute {
|
sub windows_execute {
|
||||||
my (%options) = @_;
|
my (%options) = @_;
|
||||||
my $result;
|
my $result;
|
||||||
|
@ -109,7 +119,7 @@ sub windows_execute {
|
||||||
return ($stdout, $result->{$pid}->{exitcode});
|
return ($stdout, $result->{$pid}->{exitcode});
|
||||||
}
|
}
|
||||||
|
|
||||||
sub execute {
|
sub unix_execute {
|
||||||
my (%options) = @_;
|
my (%options) = @_;
|
||||||
my $cmd = '';
|
my $cmd = '';
|
||||||
my $args = [];
|
my $args = [];
|
||||||
|
|
Loading…
Reference in New Issue