This commit is contained in:
garnier-quentin 2019-08-26 15:11:28 +02:00
parent ef884d2a8d
commit 8e7aa0b987
2 changed files with 22 additions and 7 deletions

View File

@ -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 $cluster_views = centreon::vmware::common::search_entities(command => $self, view_type => 'ComputeResource', properties => ['name', 'datastore'], filter => undef);
my $clusters = {}; my $clusters = {};
foreach my $cluster_view (@$cluster_views) { foreach my $cluster_view (@$cluster_views) {
$clusters->{view} = $cluster_view; $clusters->{$cluster_view->{name}} = {};
foreach (@{$cluster_view->{datastore}}) { foreach (@{$cluster_view->{datastore}}) {
if (defined($ds_vsan->{$_->{value}})) { if (defined($ds_vsan->{$_->{value}})) {
$clusters->{ds_vsan} = $_->{value}; $clusters->{$cluster_view->{name}}->{ds_vsan} = $_->{value};
last; 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, cluster => $cluster_view,
entityRefId => 'virtual-machine:*', entityRefId => 'virtual-machine:*',
labels => ['iopsRead', 'iopsWrite'], labels => ['iopsRead', 'iopsWrite'],
interval => $interval_sec, interval => $interval_sec,
time_shift => $self->{time_shift} time_shift => $self->{time_shift}
); );
use Data::Dumper; print Data::Dumper::Dumper($result);
} }
} }

View File

@ -707,16 +707,28 @@ sub vsan_get_performances {
my $querySpec = VsanPerfQuerySpec->new( my $querySpec = VsanPerfQuerySpec->new(
entityRefId => $options{entityRefId}, # for example: 'virtual-machine:*' entityRefId => $options{entityRefId}, # for example: 'virtual-machine:*'
labels => $options{labels}, # for example: ['iopsRead, iopsWrite'] labels => $options{labels}, # for example: ['iopsRead, iopsWrite']
startTime = $startTime, startTime => $startTime,
endTime = $endTime, endTime => $endTime,
); );
my $values = $options{vsan_performance_mgr}->VsanPerfQueryPerf( my $values = $options{vsan_performance_mgr}->VsanPerfQueryPerf(
querySpecs => [$querySpec], querySpecs => [$querySpec],
cluster => $options{cluster}, cluster => $options{cluster},
); );
use Data::Dumper; my $result = {};
print Data::Dumper::Dumper($values); 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; 1;