mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-25 14:44:43 +02:00
(plugin) apps::microsoft::hyperv::2012 - node-replication health no mapping (#3517)
This commit is contained in:
parent
01d6fcfe80
commit
04a6d65d62
@ -26,8 +26,8 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use centreon::plugins::misc;
|
use centreon::plugins::misc;
|
||||||
use centreon::common::powershell::hyperv::2012::nodereplication;
|
use centreon::common::powershell::hyperv::2012::nodereplication;
|
||||||
use apps::microsoft::hyperv::2012::local::mode::resources::types qw($node_replication_state);
|
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);
|
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
|
||||||
use JSON::XS;
|
use JSON::XS;
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
@ -36,6 +36,12 @@ sub custom_status_output {
|
|||||||
return 'replication health: ' . $self->{result_values}->{health};
|
return 'replication health: ' . $self->{result_values}->{health};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub prefix_vm_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "VM '" . $options{instance_value}->{vm} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -44,22 +50,21 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{vm} = [
|
$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' } ],
|
key_values => [ { name => 'vm' }, { name => 'state' }, { name => 'health' } ],
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
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 {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
@ -73,21 +78,12 @@ sub new {
|
|||||||
'no-ps' => { name => 'no_ps' },
|
'no-ps' => { name => 'no_ps' },
|
||||||
'ps-exec-only' => { name => 'ps_exec_only' },
|
'ps-exec-only' => { name => 'ps_exec_only' },
|
||||||
'ps-display' => { name => 'ps_display' },
|
'ps-display' => { name => 'ps_display' },
|
||||||
'filter-vm:s' => { name => 'filter_vm' },
|
'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' }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -131,9 +127,9 @@ sub manage_selection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[
|
#[
|
||||||
# { "name": "XXXX1", "state": "Replicating", "health": "Critical" },
|
# { "name": "XXXX1", "state": 2, "health": 1 },
|
||||||
# { "name": "XXXX2", "state": "Replicating", "health": "Normal" },
|
# { "name": "XXXX2", "state": 2, "health": 2 },
|
||||||
# { "name": "XXXX3", "state": "Replicating", "health": "Warning" }
|
# { "name": "XXXX3", "state": 2, "health": 2 }
|
||||||
#]
|
#]
|
||||||
$self->{vm} = {};
|
$self->{vm} = {};
|
||||||
my $id = 1;
|
my $id = 1;
|
||||||
@ -147,7 +143,7 @@ sub manage_selection {
|
|||||||
$self->{vm}->{$id} = {
|
$self->{vm}->{$id} = {
|
||||||
vm => $node->{name},
|
vm => $node->{name},
|
||||||
state => $node_replication_state->{ $node->{state} },
|
state => $node_replication_state->{ $node->{state} },
|
||||||
health => $node->{health}
|
health => $node_replication_health->{ $node->{health} }
|
||||||
};
|
};
|
||||||
$id++;
|
$id++;
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,15 @@ use warnings;
|
|||||||
use Exporter;
|
use Exporter;
|
||||||
|
|
||||||
our $node_replication_state;
|
our $node_replication_state;
|
||||||
|
our $node_replication_health;
|
||||||
our $node_vm_integration_service_operational_status;
|
our $node_vm_integration_service_operational_status;
|
||||||
our $node_vm_state;
|
our $node_vm_state;
|
||||||
our $scvmm_vm_status;
|
our $scvmm_vm_status;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT_OK = qw(
|
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
|
$node_vm_state $scvmm_vm_status
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -65,6 +67,13 @@ $node_vm_state = {
|
|||||||
32794 => 'FastSavingCritical'
|
32794 => 'FastSavingCritical'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$node_replication_health = {
|
||||||
|
0 => 'notApplicable',
|
||||||
|
1 => 'normal',
|
||||||
|
2 => 'warning',
|
||||||
|
3 => 'critical'
|
||||||
|
};
|
||||||
|
|
||||||
$node_replication_state = {
|
$node_replication_state = {
|
||||||
0 => 'Disabled',
|
0 => 'Disabled',
|
||||||
1 => 'ReadyForInitialReplication',
|
1 => 'ReadyForInitialReplication',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user