public statsGrabber(PerformanceManager perfMgr, Hashtable<String, Hashtable<String, String>> perfKeys, BlockingQueue<Object> mob_queue, BlockingQueue<Object> sender, Hashtable<String, String> appConfig, String mobType) { this.mob_queue = mob_queue; this.sender = sender; this.perfMgr = perfMgr; this.perfKeys = perfKeys; this.appConfig = appConfig; this.mobType = mobType; }
public static void main(String[] args) throws Exception { if(args.length != 3) { System.out.println("Usage: java PrintPerfMgr " + "<url> <username> <password>"); return; } ServiceInstance si = new ServiceInstance( new URL(args[0]), args[1], args[2], true); PerformanceManager perfMgr = si.getPerformanceManager(); System.out.println("***Print All Descriptions:"); PerformanceDescription pd = perfMgr.getDescription(); printPerfDescription(pd); System.out.println("\n***Print All Historical Intervals:"); PerfInterval[] pis = perfMgr.getHistoricalInterval(); printPerfIntervals(pis); System.out.println("\n***Print All Perf Counters:"); PerfCounterInfo[] pcis = perfMgr.getPerfCounter(); printPerfCounters(pcis); si.getServerConnection().logout(); }
/** * Retrieves the performance manager for this instance. * * @return the performance manager */ private PerformanceManager getPerformanceManager() { if (m_performanceManager == null) { m_performanceManager = m_serviceInstance.getPerformanceManager(); } return m_performanceManager; }
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 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(); }