1

While a am a noob in python and pyvmomi, thru the help of stackoverflow and the pyvmomi sample I have been able to get most of the information I need from ESXi servers. I want to get all the stats at the lowest level they are keeped from perfManager. All the examples I seen deal with aggregating them over a time frame.

What I think I want to do is call query = vim.PerformanceManager.QuerySpec(maxSample=1,entity=host,metricId=[metricId],startTime=startTime,endTime=endTime)

with startTime and endTime as NULL or is python None? and then iterate thru what comes back I want to save the vm, datetime of the stat, the metricId and the value. Also is there a wild card for metricId that would give me all the meticId's or do I need to call once for each metric?

I also beleve if I was to call it again later with the last datetime as the startTime and endTime as null I should get all the new stats since the last set I save? Is this correct?

Bruce C
  • 11
  • 3
  • This is how far I got – Bruce C May 08 '18 at 02:59
  • for vm in retProps: if (vm['runtime.powerState'] == "poweredOn"): #dump(perf_dict) #PrintVmInfo(vm['moref'], content, vchtime, 15, perf_dict) perfManager = content.perfManager for counter in perfList: counter_full = "{}.{}.{}".format(counter.groupInfo.key, counter.nameInfo.key, counter.rollupType) print(counter_full) print(counter.key) metricId = vim.PerformanceManager.MetricId(counterId=counter.key, instance="") – Bruce C May 08 '18 at 03:00
  • query = vim.PerformanceManager.QuerySpec(intervalId=20, entity=vm['moref'], metricId=[metricId]) perfResults = perfManager.QueryPerf(querySpec=[query]) for i in perfResults: dump(i.timestamp) – Bruce C May 08 '18 at 03:01
  • but at this point i doesn't have a attribute of timestamp. How do I access timestamp and value – Bruce C May 08 '18 at 03:02

1 Answers1

0

After much much searching I found this which had the few missing details.

https://github.com/dograga/ESXPerfData/blob/master/vmperfcollection_threaded.py

Bruce C
  • 11
  • 3