使用Python脚本从vSphere API获取实时内存利用率数据

问题描述 投票:0回答:1

我正在尝试使用python库pyvmomi.py从vSphere API获取实时内存和带宽利用率数据。到目前为止,我仅设法获取分配给VM的资源的数据。而且似乎无法找到任何方式来实时利用所有正在运行的虚拟机。我在下面添加了我的代码的一部分,以传达我正在使用的功能。寻找有关如何获取实时统计信息的想法。在这方面的任何帮助将不胜感激。谢谢。

print(c.CurrentTime())
searcher = c.content.searchIndex
vm = searcher.FindByIp(ip='10.0.10.54', vmSearch=True)
print("VM name: ", vm.config.name)
print("VM Guest OS:")
print(vm.config.guestFullName)
print("Location:")
print(vm.config.files.snapshotDirectory)
print("VM numCPU:")
print(vm.config.hardware.numCPU)
print("VM number of cores:")
print(vm.config.hardware.numCoresPerSocket)
print("RAM:")
print(vm.config.hardware.memoryMB)
python api vsphere
1个回答
0
投票
这是一个示例,应该可以帮助您开始确定可用的指标以及如何开始为脚本提取指标:https://github.com/vmware/pyvmomi-community-samples/blob/master/samples/vm_perf_example.py
© www.soinside.com 2019 - 2024. All rights reserved.