(plugin) apps::microsoft::hyperv::2012 - node-replication health no mapping (#3517)

This commit is contained in:
qgarnier 2022-03-02 09:47:43 +01:00 committed by GitHub
parent bea68e5270
commit 19df1b0b09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 25 deletions

View File

@ -26,8 +26,8 @@ use strict;
use warnings;
use centreon::plugins::misc;
use centreon::common::powershell::hyperv::2012::nodereplication;
use apps::microsoft::hyperv::2012::local::mode::resources::types qw($node_replication_state);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use apps::microsoft::hyperv::2012::local::mode::resources::types qw($node_replication_state $node_replication_health);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
use JSON::XS;
sub custom_status_output {
@ -36,6 +36,12 @@ sub custom_status_output {
return 'replication health: ' . $self->{result_values}->{health};
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub set_counters {
my ($self, %options) = @_;
@ -44,22 +50,21 @@ sub set_counters {
];
$self->{maps_counters}->{vm} = [
{ label => 'status', threshold => 0, set => {
{
label => 'status',
type => 2,
warning_default => '%{health} =~ /warning/i',
critical_default => '%{health} =~ /critical/i',
set => {
key_values => [ { name => 'vm' }, { name => 'state' }, { name => 'health' } ],
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
}
}
];
}
sub prefix_vm_output {
my ($self, %options) = @_;
return "VM '" . $options{instance_value}->{vm} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -73,21 +78,12 @@ sub new {
'no-ps' => { name => 'no_ps' },
'ps-exec-only' => { name => 'ps_exec_only' },
'ps-display' => { name => 'ps_display' },
'filter-vm:s' => { name => 'filter_vm' },
'warning-status:s' => { name => 'warning_status', default => '%{health} =~ /Warning/i' },
'critical-status:s' => { name => 'critical_status', default => '%{health} =~ /Critical/i' }
'filter-vm:s' => { name => 'filter_vm' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub manage_selection {
my ($self, %options) = @_;
@ -131,9 +127,9 @@ sub manage_selection {
}
#[
# { "name": "XXXX1", "state": "Replicating", "health": "Critical" },
# { "name": "XXXX2", "state": "Replicating", "health": "Normal" },
# { "name": "XXXX3", "state": "Replicating", "health": "Warning" }
# { "name": "XXXX1", "state": 2, "health": 1 },
# { "name": "XXXX2", "state": 2, "health": 2 },
# { "name": "XXXX3", "state": 2, "health": 2 }
#]
$self->{vm} = {};
my $id = 1;
@ -147,7 +143,7 @@ sub manage_selection {
$self->{vm}->{$id} = {
vm => $node->{name},
state => $node_replication_state->{ $node->{state} },
health => $node->{health}
health => $node_replication_health->{ $node->{health} }
};
$id++;
}

View File

@ -25,13 +25,15 @@ use warnings;
use Exporter;
our $node_replication_state;
our $node_replication_health;
our $node_vm_integration_service_operational_status;
our $node_vm_state;
our $scvmm_vm_status;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(
$node_replication_state $node_vm_integration_service_operational_status
$node_replication_state $node_replication_health
$node_vm_integration_service_operational_status
$node_vm_state $scvmm_vm_status
);
@ -65,6 +67,13 @@ $node_vm_state = {
32794 => 'FastSavingCritical'
};
$node_replication_health = {
0 => 'notApplicable',
1 => 'normal',
2 => 'warning',
3 => 'critical'
};
$node_replication_state = {
0 => 'Disabled',
1 => 'ReadyForInitialReplication',