public static void main(String[] args) throws Exception { if(args.length != 4) { System.out.println("Usage: java RealtimePerfMonitor " + "<url> <username> <password> <vmname>"); return; } ServiceInstance si = new ServiceInstance( new URL(args[0]), args[1], args[2], true); String vmname = args[3]; ManagedEntity vm = 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(); // find out the refresh rate for the virtual machine PerfProviderSummary pps = perfMgr.queryPerfProviderSummary(vm); int refreshRate = pps.getRefreshRate().intValue(); // retrieve all the available perf metrics for vm PerfMetricId[] pmis = perfMgr.queryAvailablePerfMetric( vm, null, null, refreshRate); PerfQuerySpec qSpec = createPerfQuerySpec( vm, pmis, 3, refreshRate); while(true) { PerfEntityMetricBase[] pValues = perfMgr.queryPerf( new PerfQuerySpec[] {qSpec}); if(pValues != null) { displayValues(pValues); } System.out.println("Sleeping 60 seconds..."); Thread.sleep(refreshRate*3*1000); } }
public PerfProviderSummary queryPerfProviderSummary(ManagedObjectReference morEntity) throws Exception { return _context.getService().queryPerfProviderSummary(_mor, morEntity); }
PerfProviderSummary queryPerfProviderSummary(ManagedEntity entity) throws RuntimeFault, RemoteException;