2014-10-16 26 views

回答

0

這樣做如下: 先找出計數器名稱,如果它匹配的正常運行時間,然後獲得assiciated值...

PerfObjectGetInstancesRequest p = new PerfObjectGetInstancesRequest(); 
PerfObjectGetInstancesResponse resp = apirunner.run(p.withObjectname("system")); 
Long uptime = null; 
for (InstanceData instanceInfo : (resp.getInstances())) { 
    for (int i = 0 ; i < instanceInfo.getCounters().size() ; i++) { 
    if (instanceInfo.getCounters().get(i).getName().equalsIgnoreCase("uptime")) { 
     uptime = Long.parseLong(instanceInfo.getCounters().get(i).getValue()); 
    } 
    } 
} 
相關問題