mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
fix error in logs from net-host
This commit is contained in:
parent
6c75fd1868
commit
485a4518ff
@ -1,5 +1,6 @@
|
|||||||
2020-04-06 Quentin Garnier <qgarnier@centreon.com> - 3.1.2
|
2020-04-06 Quentin Garnier <qgarnier@centreon.com> - 3.1.2
|
||||||
* Enhancement: add drs and das config enable 'cluster-status'
|
* Enhancement: add drs and das config enable 'cluster-status'
|
||||||
|
* Fix: remove errors in logs 'net-host'
|
||||||
|
|
||||||
2020-02-20 Quentin Garnier <qgarnier@centreon.com> - 3.1.1
|
2020-02-20 Quentin Garnier <qgarnier@centreon.com> - 3.1.1
|
||||||
* Fix: discovery folders management
|
* Fix: discovery folders management
|
||||||
|
@ -28,20 +28,20 @@ sub new {
|
|||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(%options);
|
my $self = $class->SUPER::new(%options);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{commandName} = 'nethost';
|
$self->{commandName} = 'nethost';
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub checkArgs {
|
sub checkArgs {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
if (defined($options{arguments}->{esx_hostname}) && $options{arguments}->{esx_hostname} eq "") {
|
if (defined($options{arguments}->{esx_hostname}) && $options{arguments}->{esx_hostname} eq '') {
|
||||||
centreon::vmware::common::set_response(code => 100, short_message => "Argument error: esx hostname cannot be null");
|
centreon::vmware::common::set_response(code => 100, short_message => 'Argument error: esx hostname cannot be null');
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ sub run {
|
|||||||
}
|
}
|
||||||
my $result = centreon::vmware::common::search_entities(command => $self, view_type => 'HostSystem', properties => \@properties, filter => $filters);
|
my $result = centreon::vmware::common::search_entities(command => $self, view_type => 'HostSystem', properties => \@properties, filter => $filters);
|
||||||
return if (!defined($result));
|
return if (!defined($result));
|
||||||
|
|
||||||
my $data = {};
|
my $data = {};
|
||||||
my $pnic_def_up = {};
|
my $pnic_def_up = {};
|
||||||
my $query_perfs = [];
|
my $query_perfs = [];
|
||||||
@ -73,7 +73,7 @@ sub run {
|
|||||||
|
|
||||||
$pnic_def_up->{$entity_value} = {};
|
$pnic_def_up->{$entity_value} = {};
|
||||||
my $instances = [];
|
my $instances = [];
|
||||||
|
|
||||||
# Get Name from vswitch
|
# Get Name from vswitch
|
||||||
if (defined($entity_view->{'config.network.vswitch'})) {
|
if (defined($entity_view->{'config.network.vswitch'})) {
|
||||||
foreach (@{$entity_view->{'config.network.vswitch'}}) {
|
foreach (@{$entity_view->{'config.network.vswitch'}}) {
|
||||||
@ -85,15 +85,16 @@ sub run {
|
|||||||
# Get Name from proxySwitch
|
# Get Name from proxySwitch
|
||||||
if (defined($entity_view->{'config.network.proxySwitch'})) {
|
if (defined($entity_view->{'config.network.proxySwitch'})) {
|
||||||
foreach (@{$entity_view->{'config.network.proxySwitch'}}) {
|
foreach (@{$entity_view->{'config.network.proxySwitch'}}) {
|
||||||
$data->{$entity_value}->{proxyswitch}->{$_->{name}} = { pnic => [] };
|
my $name = defined($_->{name}) ? $_->{name} : $_->{key};
|
||||||
|
$data->{$entity_value}->{proxyswitch}->{$name} = { pnic => [] };
|
||||||
next if (!defined($_->{pnic}));
|
next if (!defined($_->{pnic}));
|
||||||
push @{$data->{$entity_value}->{proxyswitch}->{$_->{name}}->{pnic}}, @{$_->{pnic}};
|
push @{$data->{$entity_value}->{proxyswitch}->{$name}->{pnic}}, @{$_->{pnic}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (@{$entity_view->{'config.network.pnic'}}) {
|
foreach (@{$entity_view->{'config.network.pnic'}}) {
|
||||||
$data->{$entity_value}->{pnic}->{$_->device} = { speed => undef, status => 'down', key => $_->{key} };
|
$data->{$entity_value}->{pnic}->{$_->device} = { speed => undef, status => 'down', key => $_->{key} };
|
||||||
|
|
||||||
$number_nic++;
|
$number_nic++;
|
||||||
if (defined($_->linkSpeed)) {
|
if (defined($_->linkSpeed)) {
|
||||||
$data->{$entity_value}->{pnic}->{$_->device}->{speed} = $_->linkSpeed->speedMb;
|
$data->{$entity_value}->{pnic}->{$_->device}->{speed} = $_->linkSpeed->speedMb;
|
||||||
@ -105,29 +106,31 @@ sub run {
|
|||||||
}
|
}
|
||||||
|
|
||||||
push @$query_perfs, {
|
push @$query_perfs, {
|
||||||
entity => $entity_view,
|
entity => $entity_view,
|
||||||
metrics => [
|
metrics => [
|
||||||
{label => 'net.received.average', instances => $instances},
|
{label => 'net.received.average', instances => $instances},
|
||||||
{label => 'net.transmitted.average', instances => $instances},
|
{label => 'net.transmitted.average', instances => $instances},
|
||||||
{label => 'net.droppedRx.summation', instances => $instances},
|
{label => 'net.droppedRx.summation', instances => $instances},
|
||||||
{label => 'net.droppedTx.summation', instances => $instances},
|
{label => 'net.droppedTx.summation', instances => $instances},
|
||||||
{label => 'net.packetsRx.summation', instances => $instances},
|
{label => 'net.packetsRx.summation', instances => $instances},
|
||||||
{label => 'net.packetsTx.summation', instances => $instances}
|
{label => 'net.packetsTx.summation', instances => $instances}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
# Nothing to retrieve. problem before already.
|
# Nothing to retrieve. problem before already.
|
||||||
return if (scalar(@$query_perfs) == 0);
|
return if (scalar(@$query_perfs) == 0);
|
||||||
|
|
||||||
my $values = centreon::vmware::common::generic_performance_values_historic($self->{connector},
|
my $values = centreon::vmware::common::generic_performance_values_historic(
|
||||||
undef,
|
$self->{connector},
|
||||||
$query_perfs,
|
undef,
|
||||||
$self->{connector}->{perfcounter_speriod},
|
$query_perfs,
|
||||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift},
|
$self->{connector}->{perfcounter_speriod},
|
||||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1);
|
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift},
|
||||||
|
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1
|
||||||
|
);
|
||||||
return if (centreon::vmware::common::performance_errors($self->{connector}, $values) == 1);
|
return if (centreon::vmware::common::performance_errors($self->{connector}, $values) == 1);
|
||||||
|
|
||||||
foreach my $entity_view (@$result) {
|
foreach my $entity_view (@$result) {
|
||||||
my $entity_value = $entity_view->{mo_ref}->{value};
|
my $entity_value = $entity_view->{mo_ref}->{value};
|
||||||
|
|
||||||
@ -139,7 +142,7 @@ sub run {
|
|||||||
my $packets_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.packetsTx.summation'}->{key} . ":" . $_}));
|
my $packets_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.packetsTx.summation'}->{key} . ":" . $_}));
|
||||||
my $dropped_in = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedRx.summation'}->{key} . ":" . $_}));
|
my $dropped_in = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedRx.summation'}->{key} . ":" . $_}));
|
||||||
my $dropped_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedTx.summation'}->{key} . ":" . $_}));
|
my $dropped_out = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{$self->{connector}->{perfcounter_cache}->{'net.droppedTx.summation'}->{key} . ":" . $_}));
|
||||||
|
|
||||||
$data->{$entity_value}->{pnic}->{$_}->{'net.received.average'} = $traffic_in;
|
$data->{$entity_value}->{pnic}->{$_}->{'net.received.average'} = $traffic_in;
|
||||||
$data->{$entity_value}->{pnic}->{$_}->{'net.transmitted.average'} = $traffic_out;
|
$data->{$entity_value}->{pnic}->{$_}->{'net.transmitted.average'} = $traffic_out;
|
||||||
$data->{$entity_value}->{pnic}->{$_}->{'net.packetsRx.summation'} = $packets_in;
|
$data->{$entity_value}->{pnic}->{$_}->{'net.packetsRx.summation'} = $packets_in;
|
||||||
@ -148,7 +151,7 @@ sub run {
|
|||||||
$data->{$entity_value}->{pnic}->{$_}->{'net.droppedTx.summation'} = $dropped_out;
|
$data->{$entity_value}->{pnic}->{$_}->{'net.droppedTx.summation'} = $dropped_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
centreon::vmware::common::set_response(data => $data);
|
centreon::vmware::common::set_response(data => $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user