以下是VmwareResource.java中的getVmStats中的一段代码,统计虚机的网络读取字节数,但经过测试,一直获取不到数据。
原因是因为 (perfMetrics.get(index).getCounterId() == rxPerfCounterInfo.getKey())、
(perfMetrics.get(index).getCounterId() ==
txPerfCounterInfo.getKey())条件不成立,没有获取到对应虚机的网络性能矩阵值
哪位看过这段代码,如能不吝赐教,不胜感激!
ManagedObjectReference vmMor = hyperHost.findVmOnHyperHost(name).getMor();
assert (vmMor != null);
ArrayList<PerfMetricId> vmNetworkMetrics = new ArrayList<PerfMetricId>();
// get all the metrics from the available sample period
List<PerfMetricId> perfMetrics = service.queryAvailablePerfMetric(perfMgr,
vmMor, null, null, null);
if (perfMetrics != null)
{
for (int index = 0; index < perfMetrics.size(); ++index)
{
if (((rxPerfCounterInfo != null) &&
(perfMetrics.get(index).getCounterId() == rxPerfCounterInfo.getKey())) ||
((txPerfCounterInfo != null) &&
(perfMetrics.get(index).getCounterId() == txPerfCounterInfo.getKey())))
{
vmNetworkMetrics.add(perfMetrics.get(index));
}
}
}
山东济南 崔