我已经尝试过多次迭代,但我希望我只是在完全看错东西,否则我可能是盲目的。 :-)因此,从SDK中获取信息的基本参数是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:vim25" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:RetrieveProperties>
<ns1:_this type="PropertyCollector">propertyCollector</ns1:_this>
<ns1:specSet>
<ns1:propSet>
<ns1:type>DistributedVirtualSwitch</ns1:type>
<ns1:all>true</ns1:all>
</ns1:propSet>
<ns1:objectSet>
<ns1:obj type="Folder">group-d1</ns1:obj>
<ns1:skip>false</ns1:skip>
<ns1:selectSet xsi:type="TraversalSpec">
<name>FolderTraversalSpec</name>
<type>Folder</type>
<path>childEntity</path>
<skip>false</skip>
<selectSet>
<name>FolderTraversalSpec</name>
</selectSet>
<selectSet>
<name>DataCenterVMTraversalSpec</name>
</selectSet>
</ns1:selectSet>
<ns1:selectSet xsi:type="TraversalSpec">
<name>DataCenterVMTraversalSpec</name>
<type>Datacenter</type>
<path>networkFolder</path>
<skip>false</skip>
<selectSet>
<name>FolderTraversalSpec</name>
</selectSet>
</ns1:selectSet>
</ns1:objectSet>
</ns1:specSet>
</ns1:RetrieveProperties>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
这应该为我定义的每个虚拟交换机提供所有数据。它确实...但是在应该获得一些有关网络利用率的指标的地方,我得到的都是0。特别是在runtime.resourceRuntimeInfo中。
我已经尝试通过从networkFolder中获取所有数据并获取DistributedVirtualPortgroup条目来进行处理...我已将其切换为vmFolder,并从VirtualMachine中获取了很多有用的数据。特别是在以下路径集中:guest和summary。我什至试图从hostFolder获取某种网络统计信息并获取ComputeResource类型。
[它们都不会产生输入/输出/总类型统计信息...理想情况下,我想通过端口获取它...但是在这一点上,我现在只考虑汇总虚拟交换机数据。
我愿意使用SNMP,但是我需要提供有关如何设置虚拟交换机进行监视的说明,然后……关于我唯一不能做的就是使用命令行。
任何帮助将不胜感激,因为有关VMware中网络使用情况统计信息的任何知识似乎都已被深深埋葬。
从来没有得到上面的XML为什么给我全0的地方,看起来应该有一个性能摘要,但是我终于在弄清楚如何正确查询VMWare API方面取得了一些进展。不幸的是,使用PHP有点尝试,因为VMWare的实现倾向于不完整的方面,并且没有充分的文档记录。
因此,我制作了一个使用RAW XML的基于PHP的API(因为我无法获得各种SOAP库来始终如一地提供所需的信息)。
https://github.com/matt-o-matic/PHP-VMWare-API-Class
特别是要回答我的上述问题...这是一个多步骤的过程,可以了解VMWare中任何设备上的网络使用情况。首先,您必须找出设备的ID。问题中上面的XML很好地做到了这一点。只需在输出中查找obj_id,您将获得对象ID。
从那里开始有点棘手。您还必须知道VMWare中的对象TYPE。就我而言:
获取该对象支持的度量标准ID的列表:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:QueryAvailablePerfMetric>
<urn:_this>PerfMgr</urn:_this>
<urn:entity type="VirtualMachine">vm-1844</urn:entity>
</urn:QueryAvailablePerfMetric>
</soapenv:Body>
</soapenv:Envelope>
您将获得一堆ID和实例对。最终,您将同时需要两者。但是现在,让我们看一下ID。您可以通过调用下面描述的函数来详细了解度量标准:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:QueryPerfCounter>
<urn:_this>PerfMgr</urn:_this>
<urn:counterId>125</urn:counterId>
<urn:counterId>133</urn:counterId>
<urn:counterId>143</urn:counterId>
</urn:QueryPerfCounter>
</soapenv:Body>
</soapenv:Envelope>
您可以根据需要输入任意数量的counterId ...或仅输入1。无论哪种方式都可以。在我的实例中,143是该VM对象的总网络输入和输出的ID。捕获该对象的该ID /实例(在这种情况下,实例为空白)的遥测很简单:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:QueryPerf>
<urn:_this>PerfMgr</urn:_this>
<urn:querySpec>
<urn:entity type="VirtualMachine">vm-1844</urn:entity>
<urn:startTime>2020-05-22T22:30:00Z</urn:startTime>
<urn:startTime>2020-05-22T23:30:00Z</urn:startTime>
<urn:metricId>
<urn:counterId>143</urn:counterId>
<urn:instance></urn:instance>
</urn:metricId>
<urn:format>csv</urn:format>
</urn:querySpec>
</urn:QueryPerf>
</soapenv:Body>
</soapenv:Envelope>
请注意,日期为格林尼治标准时间。除此之外,还可以直接获取一些数据。如果您想了解所有这些信息,请参阅VMWare文档。另外,通过SoapUI进行的详细查看确实帮助我了解了很多(如果我说实话,这比文档还要重要)。
只需记住在登录SoapUI中的任何其他调用后设置vmware_soap_session cookie。
希望这可以帮助其他人搜索此答案。