+ Fix netbackup plugin

This commit is contained in:
garnier-quentin 2016-02-17 10:17:08 +01:00
parent f053ed6ffa
commit 19e4f35912
6 changed files with 55 additions and 45 deletions

View File

@ -112,7 +112,7 @@ sub new {
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'nbdevquery' },
"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' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
@ -148,12 +148,12 @@ sub change_macros {
sub manage_selection {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{pool} = {};
#Disk Pool Name : NBU-MASTER-DP
#Disk Type : PureDisk
@ -238,7 +238,7 @@ Command path (Default: none).
=item B<--command-options>
Command options (Default: '-listdv -U -stype PureDisk 2>&1').
Command options (Default: '-listdv -U -stype PureDisk').
=item B<--filter-name>

View File

@ -63,7 +63,7 @@ sub new {
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tpconfig' },
"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' },
});
@ -73,12 +73,12 @@ sub new {
sub manage_selection {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{drive} = { total => 0, num_cleaning => 0 };
#Drive Name Type Mount Time Frequency Last Cleaned Comment
#********** **** ********** ********* **************** *******
@ -158,7 +158,7 @@ Command path (Default: none).
=item B<--command-options>
Command options (Default: '-l 2>&1').
Command options (Default: '-l').
=item B<--filter-name>

View File

@ -103,7 +103,7 @@ sub new {
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tpconfig' },
"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' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
@ -139,12 +139,12 @@ sub change_macros {
sub manage_selection {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{drive} = {};
#robot 0 - TLD - - - - {3,0,0,1}
# drive - 0 hcart2 2 UP - IBM.ULT3580-HH5.000 {3,0,1,0}
@ -218,7 +218,7 @@ Command path (Default: none).
=item B<--command-options>
Command options (Default: '-l 2>&1').
Command options (Default: '-l').
=item B<--filter-name>

View File

@ -221,7 +221,7 @@ sub new {
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'bpdbjobs' },
"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-end-time:s" => { name => 'filter_end_time', default => 86400 },
"ok-status:s" => { name => 'ok_status', default => '%{status} == 0' },
@ -285,12 +285,12 @@ sub manage_selection {
$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'));
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{job} = {};
my $current_time = time();
foreach my $line (split /\n/, $stdout) {
@ -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) =
($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 '' &&
$job_pname !~ /$self->{option_results}->{filter_policy_name}/) {
$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;
$self->{job}->{$display} = { display => $display, elapsed => $elapsed_time,
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) {
@ -371,7 +371,7 @@ Command path (Default: none).
=item B<--command-options>
Command options (Default: '-report -most_columns 2>&1').
Command options (Default: '-report -most_columns').
=item B<--filter-policy-name>

View File

@ -100,21 +100,21 @@ sub disco_show {
sub manage_selection {
my ($self, %options) = @_;
my $stdout = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
my ($stdout) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
$self->{policies} = {};
my @lines = split /\n/, $stdout;
foreach my $policy_name (@lines) {
my $command2 = $self->{option_results}->{command2};
$command2 =~ s/%{policy_name}/$policy_name/g;
my $stdout2 = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $command2);
my ($stdout2) = centreon::plugins::misc::execute(output => $self->{output},
options => $self->{option_results},
sudo => $self->{option_results}->{sudo},
command => $command2);
#Policy Type: NBU-Catalog (35)
#Active: yes

View File

@ -24,6 +24,16 @@ use strict;
use warnings;
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 {
my (%options) = @_;
my $result;
@ -109,7 +119,7 @@ sub windows_execute {
return ($stdout, $result->{$pid}->{exitcode});
}
sub execute {
sub unix_execute {
my (%options) = @_;
my $cmd = '';
my $args = [];