VMware {code} Community
ttdsuen
Contributor
Contributor

retreiving datastore latest usage...

I am trying to retrieve datastore usage,

I did,

my $perfmgr = Vim::get_service_content()->perfManager;

my $perfmgr_view = Vim::get_view(

    mo_ref => $perfmgr

);

my $counters = counters(perfmgr_view => $perfmgr_view);  # $counters are just array of counters, each same type as returned from $perfmgr_view->perfCounter;

# here, I am interested in group_info == 'disk', and counter's name is "used", "capacity".

my $entity_views = Vim::find_entity_views(view_type => 'Datastore');

foreach my $entity (sort { $a->name cmp $b->name } @$entity_views) {

    # here I create an array called @$filtered_counters, each is of type returned from $perfmgr_view->QueryAvailablePerfMetric($entity) - basically only ask for supported metrics of this entity (subset of { disk/used, disk/capacity })

   my $start = ...; (YYYY-MM-DDTHH:MM::SSZ basically gmtime(time) - 1800 (half an hour before now in UTC)

    my $perf_query_spec = PerfQuerySpec->new(

        entity => $entity,

        metricId => [ map { $_->{counter} } @$filtered_counters ],

        format => 'csv',

        intervalId => 300,

        startTime => $start

#        endTime => $end

    );

    my $perf_data = $perfmgr_view->QueryPerf(querySpec => $perf_query_spec);

   print Dumper($perf_data);

}

The thing is, after I ran the above code, I got some latest sample points with SampleInfoCSV having timestamp outside of the range I specified (above, I did not specify endTime, even if I do, I still get some sampleInfoCSV out of the date range I specified). Interesting enough, this happens more or less random. For instance, for datastore A, I run it now, I got a point in the date range (close to now), and I run it 5 minutes later, I get a point outside of the date range (before startTime), did anyone hit this? Or I miss something? Appreciate if someone can help. Thanks.

Daniel.

Reply
0 Kudos
0 Replies