diff --git a/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm b/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm index d11bce3a4..06ca1670f 100644 --- a/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm +++ b/connectors/vmware/src/centreon/vmware/cmddatastoreiops.pm @@ -146,21 +146,24 @@ sub run { my $cluster_views = centreon::vmware::common::search_entities(command => $self, view_type => 'ComputeResource', properties => ['name', 'datastore'], filter => undef); my $clusters = {}; foreach my $cluster_view (@$cluster_views) { - $clusters->{view} = $cluster_view; + $clusters->{$cluster_view->{name}} = {}; foreach (@{$cluster_view->{datastore}}) { if (defined($ds_vsan->{$_->{value}})) { - $clusters->{ds_vsan} = $_->{value}; + $clusters->{$cluster_view->{name}}->{ds_vsan} = $_->{value}; last; } } - centreon::vmware::common::vsan_get_performances( + next if (!defined($clusters->{$cluster_view->{name}}->{ds_vsan})); + my $result = centreon::vmware::common::vsan_get_performances( + vsan_performance_mgr => $vsan_performance_mgr, cluster => $cluster_view, entityRefId => 'virtual-machine:*', labels => ['iopsRead', 'iopsWrite'], interval => $interval_sec, time_shift => $self->{time_shift} ); + use Data::Dumper; print Data::Dumper::Dumper($result); } } diff --git a/connectors/vmware/src/centreon/vmware/common.pm b/connectors/vmware/src/centreon/vmware/common.pm index 1309737a8..e8ecbfe5b 100644 --- a/connectors/vmware/src/centreon/vmware/common.pm +++ b/connectors/vmware/src/centreon/vmware/common.pm @@ -707,16 +707,28 @@ sub vsan_get_performances { my $querySpec = VsanPerfQuerySpec->new( entityRefId => $options{entityRefId}, # for example: 'virtual-machine:*' labels => $options{labels}, # for example: ['iopsRead, iopsWrite'] - startTime = $startTime, - endTime = $endTime, + startTime => $startTime, + endTime => $endTime, ); my $values = $options{vsan_performance_mgr}->VsanPerfQueryPerf( querySpecs => [$querySpec], cluster => $options{cluster}, ); - use Data::Dumper; - print Data::Dumper::Dumper($values); + my $result = {}; + foreach (@$values) { + $result->{$_->{entityRefId}} = {}; + foreach my $perf (@{$_->{value}}) { + my ($counter, $i) = (0, 0); + foreach my $val (split /,/, $perf->{values}) { + $counter += $val; + $i++; + } + $result->{$_->{entityRefId}}->{$perf->{metricId}->{label}} = $counter / $i; + } + } + + return $result; } 1;