"QueryPerf" vSphere 的方法API returns 奇怪的结果

"QueryPerf" method of vSphere API returns strange results

我需要获取给定 VM 的平均每日统计信息。 VM 在 VMware vSphere 5.1 上运行。我使用 PHP 并通过 SOAP 调用方法。

我的代码如下所示:

$result = $this
        ->soapClient
        ->QueryPerf( array(
            '_this' => $this->serviceContent->perfManager,
            'querySpec' => array(
                'entity'        => $object,
                'startTime'     => $startTime->format( 'c' ),
                'intervalId'    => 86400,
            ),
        ) );

CPU 间隔期间的使用百分比和内存使用占总配置或可用内存百分比的返回结果看起来很奇怪。

CPU 结果:

  stdClass::__set_state(array(
     'groupInfo' => 
    stdClass::__set_state(array(
       'label' => 'CPU',
       'summary' => 'CPU',
       'key' => 'cpu',
    )),
     'nameInfo' => 
    stdClass::__set_state(array(
       'label' => 'Usage',
       'summary' => 'CPU usage as a percentage during the interval',
       'key' => 'usage',
    )),
     'rollupType' => 'average',
     'statsType' => 'rate',
     'unitInfo' => 
    stdClass::__set_state(array(
       'label' => 'Percent',
       'summary' => 'Percentage',
       'key' => 'percent',
    )),
     'instance' => '',
     'value' => 349,
  )),

单位是百分比但是数值是349.

记忆结果:

  stdClass::__set_state(array(
     'groupInfo' => 
    stdClass::__set_state(array(
       'label' => 'Memory',
       'summary' => 'Memory',
       'key' => 'mem',
    )),
     'nameInfo' => 
    stdClass::__set_state(array(
       'label' => 'Usage',
       'summary' => 'Memory usage as percentage of total configured or available memory',
       'key' => 'usage',
    )),
     'rollupType' => 'average',
     'statsType' => 'absolute',
     'unitInfo' => 
    stdClass::__set_state(array(
       'label' => 'Percent',
       'summary' => 'Percentage',
       'key' => 'percent',
    )),
     'instance' => '',
     'value' => 1193,
  )),

单位也是百分比但是数值是1193.

其他值也有同样的问题。

问题: 我究竟做错了什么? 如何获得有效结果?

注意:这些结果稍微经过格式化,但没有在客户端执行任何计算或其他值修改。

look at the docs。您应该将百分比值除以 100,以获得实际百分比值。