pyvmomi获取RAM/CPU使用率VSphere SDK 5.5? [英] pyvmomi Get RAM/CPU Usage VSphere SDK 5.5?

查看:147
本文介绍了pyvmomi获取RAM/CPU使用率VSphere SDK 5.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Python从一些ESXi服务器中获取一些信息.我发现pyvmomi( https://github.com/vmware/pyvmomi )非常好用了解用于此目的的工具.但是,我似乎找不到找到有关CPU/RAM/存储使用情况的实时"信息的方法.我正在查看VMware的SDK(

I am trying to get some information from a few ESXi Servers through Python. I found pyvmomi(https://github.com/vmware/pyvmomi) which is a great and easy to understand tool for this purpose. However, I cannot seem to find a way to get "real-time" info on the CPU/RAM/Storage usage. I am going through the SDK of VMware (http://pubs.vmware.com/vsphere-55/topic/com.vmware.sdk.doc/GUID-19793BCA-9EAB-42E2-8B9F-F9F2129E7741.html) but I can only find how many cpus or how much memory the host has.

有人通过Python完成此操作吗?

Has anyone ever done this through Python?

推荐答案

检查 pyvmomi-community-样本.其中有一个名为esxi_perf_sample.py的python脚本,其中包含有关如何在指定时间段内检索特定指标的示例.

Check the pyvmomi-community-samples. There's a python script in there called esxi_perf_sample.py with an example on how to retrieve a specific metric in a specified period of time.

连同该示例一起,检查实施.

Along with that example, check this implementation.

此处的窍门在于将counterId映射到目标计算机上当前实现的可用度量的人类可读名称.您应先检索可用的计数器,然后再尝试获取它们的值.

The trick here resides on the counterId mapping into human-readable names of the available metrics that are currently implemented on the target machine. You should first retrieve the available counters before you attempt to retrieve their values.

我认为,本文的第二个链接的实现是您在撰写本文时基于pyVmomi找到的最佳公开示例之一.请仔细研究它,因为它可能会回答您所有的疑问.

In my opinion, the implementation of the second link of this post is one of the best public examples that you'll find based on pyVmomi at the time of this writing. Take a careful look into it as it will probably answer all your doubts for itself.

还请注意,尽管Geeklee vminfo实现是面向来宾的,但所有度量标准仍对主机有效.执行查询时,您只需要修改脚本以指定主机实体而不是Guest(或同时允许两者)即可.

Also note that although the Geeklee vminfo implementation is Guest oriented, all the metrics are still valid for the Host. You just need to adapt the script to specify the Host entity instead of the Guest (or allow both) when you perform the query.

最后,在执行查询调用时,可以通过时间间隔来指定检索到的指标的实时"粒度.您应根据需要指定间隔,但请注意,对于最新的vSphere版本,样本之间的最小(默认)间隔为20秒,因此,您所指定的时间间隔不应小于此值.

Finally, the "real-time" granularity for the retrieved metrics can be specified by a time interval when performing the query call. You should specify an interval based on your needs, but note that for the latest vSphere versions, the minimum (default) interval between samples is 20 seconds, so you should not specify a time interval lesser than this value.

这篇关于pyvmomi获取RAM/CPU使用率VSphere SDK 5.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆