enh netbackup jobstatus, add exec-only option

This commit is contained in:
Colin Gagnaire 2019-01-28 14:54:51 +01:00
parent c4d6dd41fb
commit 671a27fccd
5 changed files with 128 additions and 53 deletions

View File

@ -88,19 +88,20 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'nbdevquery' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-listdp -U' },
"command2:s" => { name => 'command2', default => 'nbdevquery' },
"command2-path:s" => { name => 'command2_path' },
"command2-options:s" => { name => 'command2_options', default => '-listdv -U -stype PureDisk' },
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'nbdevquery' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-listdp -U' },
"command2:s" => { name => 'command2', default => 'nbdevquery' },
"command2-path:s" => { name => 'command2_path' },
"command2-options:s" => { name => 'command2_options', default => '-listdv -U -stype PureDisk' },
"exec-only" => { name => 'exec_only' },
"filter-name:s" => { name => 'filter_name' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
@ -131,7 +132,13 @@ sub manage_selection {
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
}
#Disk Pool Name : NBU-MASTER-DP
#Disk Pool Id : NBU-MASTER-DP
#Disk Type : PureDisk
@ -159,6 +166,14 @@ sub manage_selection {
command => $self->{option_results}->{command2},
command_path => $self->{option_results}->{command2_path},
command_options => $self->{option_results}->{command2_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{volume} = {};
#Disk Pool Name : NBU-MASTER-DP
#Disk Type : PureDisk
@ -260,6 +275,10 @@ Command path (Default: none).
Command options (Default: '-listdv -U -stype PureDisk').
=item B<--exec-only>
Print command output
=item B<--filter-name>
Filter pool name (can be a regexp).

View File

@ -64,6 +64,7 @@ sub new {
"command:s" => { name => 'command', default => 'tpconfig' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-l' },
"exec-only" => { name => 'exec_only' },
"filter-name:s" => { name => 'filter_name' },
});
@ -78,7 +79,15 @@ sub manage_selection {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{drive} = { total => 0, num_cleaning => 0 };
#Drive Name Type Mount Time Frequency Last Cleaned Comment
#********** **** ********** ********* **************** *******
@ -160,6 +169,10 @@ Command path (Default: none).
Command options (Default: '-l').
=item B<--exec-only>
Print command output
=item B<--filter-name>
Filter drive name (can be a regexp).

View File

@ -69,16 +69,17 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tpconfig' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-l' },
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"sudo" => { name => 'sudo' },
"command:s" => { name => 'command', default => 'tpconfig' },
"command-path:s" => { name => 'command_path' },
"command-options:s" => { name => 'command_options', default => '-l' },
"exec-only" => { name => 'exec_only' },
"filter-name:s" => { name => 'filter_name' },
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /up/i' },
@ -108,7 +109,15 @@ sub manage_selection {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{drive} = {};
#robot 0 - TLD - - - - {3,0,0,1}
# drive - 0 hcart2 2 UP - IBM.ULT3580-HH5.000 {3,0,1,0}
@ -184,6 +193,10 @@ Command path (Default: none).
Command options (Default: '-l').
=item B<--exec-only>
Print command output
=item B<--filter-name>
Filter drive name (can be a regexp).

View File

@ -45,7 +45,7 @@ sub custom_status_threshold {
eval "$self->{instance_mode}->{option_results}->{critical_status}") {
$status = 'critical';
} elsif (defined($self->{instance_mode}->{option_results}->{warning_status}) && $self->{instance_mode}->{option_results}->{warning_status} ne '' &&
eval "$self->{instance_mode}->{option_results}->{warning_status}") {
eval "$self->{instance_mode}->{option_results}->{warning_status}") {
$status = 'warning';
}
};
@ -58,7 +58,7 @@ sub custom_status_threshold {
sub custom_status_output {
my ($self, %options) = @_;
my $msg = 'status : ' . $self->{result_values}->{status};
my $msg = 'Status : ' . $self->{result_values}->{status};
return $msg;
}
@ -75,7 +75,7 @@ sub custom_status_calc {
sub custom_long_output {
my ($self, %options) = @_;
my $msg = 'started since : ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
my $msg = 'Started Since: ' . centreon::plugins::misc::change_seconds(value => $self->{result_values}->{elapsed});
return $msg;
}
@ -107,7 +107,7 @@ sub custom_frozen_threshold {
eval "$self->{instance_mode}->{option_results}->{critical_frozen}") {
$status = 'critical';
} elsif (defined($self->{instance_mode}->{option_results}->{warning_frozen}) && $self->{instance_mode}->{option_results}->{warning_frozen} ne '' &&
eval "$self->{instance_mode}->{option_results}->{warning_frozen}") {
eval "$self->{instance_mode}->{option_results}->{warning_frozen}") {
$status = 'warning';
}
};
@ -121,10 +121,10 @@ sub custom_frozen_threshold {
sub custom_frozen_output {
my ($self, %options) = @_;
my $msg = 'frozen : no';
my $msg = "Frozen: 'no'";
if (!$self->{output}->is_status(value => $self->{instance_mode}->{last_status_frozen}, compare => 'ok', litteral => 1)) {
$msg = 'frozen: yes';
$msg = "Frozen: 'yes'";
}
return $msg;
}
@ -150,7 +150,8 @@ sub set_counters {
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'policy', type => 2, cb_prefix_output => 'prefix_policy_output', cb_long_output => 'policy_long_output', message_multiple => 'All policies are ok',
{ name => 'policy', type => 2, cb_prefix_output => 'prefix_policy_output', cb_long_output => 'policy_long_output',
message_multiple => 'All policies are ok',
group => [ { name => 'job', cb_prefix_output => 'prefix_job_output', skipped_code => { -11 => 1 } } ]
}
];
@ -176,7 +177,8 @@ sub set_counters {
}
},
{ label => 'long', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'type' }, { name => 'state' } ],
key_values => [ { name => 'status' }, { name => 'display' }, { name => 'elapsed' }, { name => 'type' },
{ name => 'state' } ],
closure_custom_calc => $self->can('custom_long_calc'),
closure_custom_output => $self->can('custom_long_output'),
closure_custom_perfdata => sub { return 0; },
@ -204,16 +206,17 @@ sub new {
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"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' },
"hostname:s" => { name => 'hostname' },
"remote" => { name => 'remote' },
"ssh-option:s@" => { name => 'ssh_option' },
"ssh-path:s" => { name => 'ssh_path' },
"ssh-command:s" => { name => 'ssh_command', default => 'ssh' },
"timeout:s" => { name => 'timeout', default => 30 },
"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' },
"exec-only" => { name => 'exec_only' },
"filter-policy-name:s" => { name => 'filter_policy_name' },
"filter-type:s" => { name => 'filter_type' },
"filter-end-time:s" => { name => 'filter_end_time', default => 86400 },
@ -234,25 +237,26 @@ sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['ok_status', 'warning_status', 'critical_status', 'warning_long', 'critical_long', 'warning_frozen', 'critical_frozen']);
$self->change_macros(macros => ['ok_status', 'warning_status', 'critical_status', 'warning_long',
'critical_long', 'warning_frozen', 'critical_frozen']);
}
sub policy_long_output {
my ($self, %options) = @_;
return "checking policy '" . $options{instance_value}->{display} . "'";
return "Checking policy '" . $options{instance_value}->{display} . "'";
}
sub prefix_policy_output {
my ($self, %options) = @_;
return "policy '" . $options{instance_value}->{display} . "' ";
return "Policy '" . $options{instance_value}->{display} . "' ";
}
sub prefix_job_output {
my ($self, %options) = @_;
return "job '" . $options{instance_value}->{display} . "' ";
return "Job '" . $options{instance_value}->{display} . "' [Type: " . $options{instance_value}->{type} . "] [State: " . $options{instance_value}->{state} . "] " ;
}
my %job_type = (
@ -288,8 +292,15 @@ sub manage_selection {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{global} = { total => 0 };
$self->{policy} = {};
my $current_time = time();
@ -324,9 +335,12 @@ sub manage_selection {
$self->{policy}->{$job_pname} = { job => {}, display => $job_pname } if (!defined($self->{policy}->{$job_pname}));
my $elapsed_time = $current_time - $job_start_time;
$self->{policy}->{$job_pname}->{job}->{$job_id} = {
display => $job_id, elapsed => $elapsed_time,
status => $job_status, state => $job_state{$job_state}, type => $job_type{$job_type},
kb => defined($job_kb) && $job_kb =~ /[0-9]+/ ? $job_kb : undef,
display => $job_id,
elapsed => $elapsed_time,
status => $job_status,
state => $job_state{$job_state},
type => $job_type{$job_type},
kb => defined($job_kb) && $job_kb =~ /[0-9]+/ ? $job_kb : '0',
parentid => defined($job_parentid) ? $job_parentid : '',
jobid => $job_id,
schedule => defined($job_schedule) ? $job_schedule : '',
@ -386,6 +400,10 @@ Command path (Default: none).
Command options (Default: '-report -most_columns').
=item B<--exec-only>
Print command output
=item B<--filter-policy-name>
Filter job policy name (can be a regexp).

View File

@ -148,7 +148,15 @@ sub manage_selection {
sudo => $self->{option_results}->{sudo},
command => $self->{option_results}->{command},
command_path => $self->{option_results}->{command_path},
command_options => $self->{option_results}->{command_options});
command_options => $self->{option_results}->{command_options});
if (defined($self->{option_results}->{exec_only})) {
$self->{output}->output_add(severity => 'OK',
short_msg => $stdout);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
$self->{global} = { total => 0, used => 0 };
#media optical media barcode robot robot robot robot side/ volume prev # of max # of create assigned first mount last mount expiration off sent off return off off
#ID partner type barcode partner host type # slot face group pool pool # pool mounts mounts cleanings datetime datetime datetime datetime datetime status offsite location datetime datetime slot ses id version description
@ -229,6 +237,10 @@ Command path (Default: none).
Command options (Default: '-a -w').
=item B<--exec-only>
Print command output
=item B<--filter-scratch>
Filter tape scratch (Default: 'scratch').