enh(veeam): create new perfdata (#3004)

This commit is contained in:
qgarnier 2021-07-30 13:51:32 +02:00 committed by GitHub
parent f3518f4046
commit 184f9d6075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 32 deletions

View File

@ -26,7 +26,7 @@ use strict;
use warnings;
use centreon::common::powershell::veeam::jobstatus;
use apps::backup::veeam::local::mode::resources::types qw($job_type $job_result);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::misc;
use JSON::XS;
@ -65,7 +65,7 @@ sub set_counters {
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
{ label => 'total', nlabel => 'jobs.total.count', set => {
key_values => [ { name => 'total' } ],
output_template => 'Total Jobs : %s',
perfdatas => [
@ -78,7 +78,6 @@ sub set_counters {
$self->{maps_counters}->{job} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'status' }, { name => 'display' }, { name => 'type' }, { name => 'is_running' } ],
closure_custom_calc => \&catalog_status_calc,
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold

View File

@ -26,7 +26,7 @@ use strict;
use warnings;
use centreon::common::powershell::veeam::tapejobs;
use apps::backup::veeam::local::mode::resources::types qw($job_tape_type $job_tape_result $job_tape_state);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use centreon::plugins::misc;
use JSON::XS;
@ -41,6 +41,12 @@ sub custom_status_output {
);
}
sub prefix_job_output {
my ($self, %options) = @_;
return "Tape job '" . $options{instance_value}->{display} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
@ -61,7 +67,7 @@ sub set_counters {
];
$self->{maps_counters}->{job} = [
{ label => 'status', threshold => 0, set => {
{ label => 'status', type => 2, critical => '%{enabled} == 1 and not %{last_result} =~ /Success|None/i', set => {
key_values => [
{ name => 'display' }, { name => 'enabled' },
{ name => 'type' }, { name => 'last_result' },
@ -69,7 +75,7 @@ sub set_counters {
],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
}
];
@ -81,36 +87,20 @@ sub new {
bless $self, $class;
$options{options}->add_options(arguments => {
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' },
'unknown-status:s' => { name => 'unknown_status', default => '' },
'warning-status:s' => { name => 'warning_status', default => '' },
'critical-status:s' => { name => 'critical_status', default => '%{enabled} == 1 and not %{last_result} =~ /Success|None/i' }
'timeout:s' => { name => 'timeout', default => 50 },
'command:s' => { name => 'command', default => 'powershell.exe' },
'command-path:s' => { name => 'command_path' },
'command-options:s' => { name => 'command_options', default => '-InputFormat none -NoLogo -EncodedCommand' },
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-name:s' => { name => 'filter_name' },
'filter-type:s' => { name => 'filter_type' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
}
sub prefix_job_output {
my ($self, %options) = @_;
return "Tape job '" . $options{instance_value}->{display} . "' ";
}
sub manage_selection {
my ($self, %options) = @_;
@ -171,7 +161,7 @@ sub manage_selection {
$self->{output}->output_add(long_msg => "skipping job '" . $job->{name} . "': no matching filter type.", debug => 1);
next;
}
$self->{job}->{ $job->{name} } = {
display => $job->{name},
type => $job_tape_type->{ $job->{type} },