Java 类com.vmware.vim25.PerfCompositeMetric 实例源码

项目:vijava    文件:GetMultiPerf.java   
public static void main(String[] args) throws Exception
{
  if(args.length != 4)
  {
    System.out.println("Usage: java GetMultiPerf " 
      + "<url> <username> <password> <vmname>");
    return;
  }

  ServiceInstance si = new ServiceInstance(
    new URL(args[0]), args[1], args[2], true);

  String vmname = args[3];
  VirtualMachine vm = (VirtualMachine) new InventoryNavigator(
    si.getRootFolder()).searchManagedEntity(
      "VirtualMachine", vmname);

  if(vm == null)
  {
    System.out.println("Virtual Machine " + vmname 
        + " cannot be found.");
    si.getServerConnection().logout();
    return;
  }

  PerformanceManager perfMgr = si.getPerformanceManager();

  int perfInterval = 1800; // 30 minutes for PastWeek

  // retrieve all the available perf metrics for vm
  PerfMetricId[] pmis = perfMgr.queryAvailablePerfMetric(
      vm, null, null, perfInterval);

  Calendar curTime = si.currentTime();

  PerfQuerySpec qSpec = new PerfQuerySpec();
  qSpec.setEntity(vm.getRuntime().getHost());
  //metricIDs must be provided, or InvalidArgumentFault 
  qSpec.setMetricId(pmis);
  qSpec.setFormat("normal"); //optional since it's default
  qSpec.setIntervalId(perfInterval); 

  Calendar startTime = (Calendar) curTime.clone();
  startTime.roll(Calendar.DATE, -4);
  System.out.println("start:" + startTime.getTime());
  qSpec.setStartTime(startTime);

  Calendar endTime = (Calendar) curTime.clone();
  endTime.roll(Calendar.DATE, -3);
  System.out.println("end:" + endTime.getTime());
  qSpec.setEndTime(endTime);

  PerfCompositeMetric pv = perfMgr.queryPerfComposite(qSpec);
  if(pv != null)
  {
    printPerfMetric(pv.getEntity());
    PerfEntityMetricBase[] pembs = pv.getChildEntity();
    for(int i=0; pembs!=null && i< pembs.length; i++)
    {
      printPerfMetric(pembs[i]);
    }
  }
  si.getServerConnection().logout();
}
项目:cloudstack    文件:PerfManagerMO.java   
public PerfCompositeMetric queryPerfComposite(PerfQuerySpec spec) throws Exception {
    return _context.getService().queryPerfComposite(_mor, spec);
}
项目:jcloud-vsphere    文件:PerformanceManagerApi.java   
PerfCompositeMetric queryPerfComposite(PerfQuerySpec querySpec) throws RuntimeFault, RemoteException;