List of usage examples for java.util Calendar roll
public void roll(int field, int amount)
From source file:fr.paris.lutece.plugins.calendar.service.XMLUtils.java
/** * Get the XML of a calendar/*w ww. jav a 2 s . c o m*/ * @param local The locale * @param cal The calendar * @param request The request * @return The XML */ public static String getXMLPortletCalendar(Locale local, Calendar cal, HttpServletRequest request) { StringBuffer strXml = new StringBuffer(); String strDay = null; Calendar calendar = new GregorianCalendar(); //Set the calendar in the beginning of the month calendar.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), 1); int nDayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); //If day of week is sunday: nDayOfWeek = 8 if (nDayOfWeek == 1) { nDayOfWeek = 8; } Calendar calendar2 = new GregorianCalendar(); calendar2.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), calendar.getMaximum(Calendar.DAY_OF_MONTH)); //Beginning of the main xml block: month XmlUtil.beginElement(strXml, TAG_AGENDA_MONTH); String strBaseUrl = AppPathService.getPortalUrl(); UrlItem urlMonth = new UrlItem(strBaseUrl); urlMonth.addParameter(Constants.PARAMETER_PAGE, Constants.PLUGIN_NAME); urlMonth.addParameter(Constants.PARAMETER_ACTION, Constants.ACTION_DO_SEARCH); urlMonth.addParameter(Constants.PARAMETER_DATE_START, DateUtil.getDateString(calendar.getTime(), local)); urlMonth.addParameter(Constants.PARAMETER_DATE_END, DateUtil.getDateString(calendar2.getTime(), local)); urlMonth.addParameter(Constants.PARAMETER_PERIOD, Constants.PROPERTY_PERIOD_RANGE); String strMonthLabel = Utils.getMonthLabel(Utils.getDate(calendar), local); String strUrlMonth = BEGIN_A_TAG + urlMonth.getUrl() + "\">" + strMonthLabel + END_A_TAG; XmlUtil.addElementHtml(strXml, TAG_AGENDA_MONTH_LABEL, strUrlMonth); //Shortcut tags //Begenning of the xml block: week-shortcuts XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUTS); //Today shortcut XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_TODAY, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_TODAY); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(new Date(), local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(new Date(), local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Tomorrow shortcut Calendar calTomorrow = new GregorianCalendar(); calTomorrow.add(Calendar.DATE, 1); XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_TOMORROW, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_RANGE); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(calTomorrow.getTime(), local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(calTomorrow.getTime(), local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Week shortcut Date dateBeginWeek = null; Date dateEndWeek = null; Calendar calendarToday = new GregorianCalendar(); Calendar calendarFirstDay = Calendar.getInstance(); Calendar calendarLastDay = new GregorianCalendar(); calendarFirstDay = calendarToday; calendarFirstDay.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendarLastDay = (GregorianCalendar) calendarFirstDay.clone(); calendarLastDay.add(Calendar.DATE, 6); dateBeginWeek = calendarFirstDay.getTime(); dateEndWeek = calendarLastDay.getTime(); XmlUtil.beginElement(strXml, TAG_WEEK_SHORTCUT); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTCUT_WEEK, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_PERIOD, Constants.PROPERTY_PERIOD_WEEK); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_START, DateUtil.getDateString(dateBeginWeek, local)); XmlUtil.addElement(strXml, TAG_WEEK_SHORTCUT_DATE_END, DateUtil.getDateString(dateEndWeek, local)); XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUT); //Ending of the xml block: week-shortcuts XmlUtil.endElement(strXml, TAG_WEEK_SHORTCUTS); //Begenning of the xml block: weeks XmlUtil.beginElement(strXml, TAG_AGENDA_WEEKS); //Day label tags XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_MONDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_TUESDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_WEDNESDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_THURSDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_FRIDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_SATURDAY, local)); XmlUtil.addElement(strXml, TAG_AGENDA_DAY_LABEL, I18nService.getLocalizedString(Constants.PROPERTY_SHORTLABEL_SUNDAY, local)); //Check if the month is ended boolean bDone = false; //check if the month is started boolean bStarted = false; //While the month isn't over... while (!bDone) { //Begenning of the xml block: week XmlUtil.beginElement(strXml, TAG_AGENDA_WEEK); for (int i = 0; i < 7; i++) { if ((((i + 2) != nDayOfWeek) && !bStarted) || bDone) { XmlUtil.beginElement(strXml, TAG_AGENDA_DAY); strDay = BEGIN_TD_TAG + getDayClass(calendar) + ">" + PROPERTY_EMPTY_DAY + END_TD_TAG; XmlUtil.addElementHtml(strXml, TAG_AGENDA_DAY_CODE, strDay); XmlUtil.endElement(strXml, TAG_AGENDA_DAY); continue; } bStarted = true; //put parameters in the url UrlItem urlDay = new UrlItem(strBaseUrl); String strPageId = request != null ? request.getParameter(Constants.PARAMETER_PAGE_ID) : StringUtils.EMPTY; if (StringUtils.isNotBlank(strPageId) && StringUtils.isNumeric(strPageId)) { urlDay.addParameter(Constants.PARAMETER_PAGE_ID, strPageId); } urlDay.addParameter(Constants.PARAMETER_DATE, DateUtil.getDateString(calendar.getTime(), local)); //construct on url based on day String strUrlDay = new String(); strUrlDay = BEGIN_A_TAG + urlDay.getUrl() + "\">" + Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)) + END_A_TAG; XmlUtil.beginElement(strXml, TAG_AGENDA_DAY); Date date = Utils.getDate(Utils.getDate(calendar)); Plugin plugin = PluginService.getPlugin(CalendarPlugin.PLUGIN_NAME); String[] arrayCalendarIds = Utils.getCalendarIds(request); List<Event> listEvent = CalendarSearchService.getInstance().getSearchResults(arrayCalendarIds, null, "", date, date, plugin); if (listEvent.size() != 0) { strDay = BEGIN_TD_TAG + Constants.STYLE_CLASS_SMALLMONTH_DAY + Constants.STYLE_CLASS_SUFFIX_EVENT + ">" + BEGIN_BOLD_TAG + strUrlDay + END_BOLD_TAG + END_TD_TAG; } else { strDay = BEGIN_TD_TAG + getDayClass(calendar) + ">" + Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)) + END_TD_TAG; } XmlUtil.addElementHtml(strXml, TAG_AGENDA_DAY_CODE, strDay); XmlUtil.endElement(strXml, TAG_AGENDA_DAY); int nDay = calendar.get(Calendar.DAY_OF_MONTH); calendar.roll(Calendar.DAY_OF_MONTH, true); int nNewDay = calendar.get(Calendar.DAY_OF_MONTH); if (nNewDay < nDay) { bDone = true; } } //Ending of the xml block: week XmlUtil.endElement(strXml, TAG_AGENDA_WEEK); } //Ending of the xml block: weeks XmlUtil.endElement(strXml, TAG_AGENDA_WEEKS); //Ending of the xml block: month XmlUtil.endElement(strXml, TAG_AGENDA_MONTH); return strXml.toString(); }
From source file:com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance.java
/** * Sets the end time.//from w w w.ja v a2s.co m * @param process the process * @param val the val */ public void setEndTime(final String process, int val) { if (val > 0) { long end_day; final Calendar calendar = Calendar.getInstance(); if (val >= 30) { while (val >= 30) { if (calendar.get(Calendar.MONTH) == 11) calendar.roll(Calendar.YEAR, true); calendar.roll(Calendar.MONTH, true); val -= 30; } } if (val < 30 && val > 0) { while (val > 0) { if (calendar.get(Calendar.DATE) == 28 && calendar.get(Calendar.MONTH) == 1) calendar.roll(Calendar.MONTH, true); if (calendar.get(Calendar.DATE) == 30) { if (calendar.get(Calendar.MONTH) == 11) calendar.roll(Calendar.YEAR, true); calendar.roll(Calendar.MONTH, true); } calendar.roll(Calendar.DATE, true); val--; } } end_day = calendar.getTimeInMillis(); if (process.equals("aio")) _aio_endTime = end_day; else { LOGGER.info("process " + process + "no Known while try set end date"); return; } final Date dt = new Date(end_day); LOGGER.info("" + process + " end time for player " + getName() + " is " + dt); } else { if (process.equals("aio")) _aio_endTime = 0; else { LOGGER.info("process " + process + "no Known while try set end date"); return; } } }
From source file:net.siveo.virtualization.vmware.Main.java
public void getVAppPerformance() throws VMwareException { // =================================================================================== // Connection to the VirtualCenter // =================================================================================== String hostName = "10.251.5.14"; VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L); // =================================================================================== // Get all ResourcePool from the VC // =================================================================================== ArrayList<TreeNode> listOfTreenodes = new ArrayList<TreeNode>(); //InventoryManager inventoryManager=InventoryManager.getInstance(); //listOfTreenodes=inventoryManager.getTreeNodeByType("ResourcePool", hostName); VirtualAppManager virtualAppManager = VirtualAppManager.getInstance(); listOfTreenodes.addAll(virtualAppManager.getAllVApp(hostName)); // =================================================================================== // Create the "Performance Engine" // -------------------------------------------------------------- PerformanceManager performanceManager = PerformanceManager.getInstance(); Performance performance = performanceManager.create(hostName); // =================================================================================== // Build the StartTime and the EndTime // =================================================================================== SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS"); Calendar curTime = performance.getCurrentDateTime(); Calendar startTime = (Calendar) curTime.clone(); startTime.set(Calendar.HOUR_OF_DAY, 23); startTime.set(Calendar.MINUTE, 00); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); Calendar endTime = (Calendar) curTime.clone(); endTime.set(Calendar.HOUR_OF_DAY, 22); endTime.set(Calendar.MINUTE, 59); endTime.set(Calendar.SECOND, 59); endTime.set(Calendar.MILLISECOND, 00); endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1); startTime.roll(Calendar.DATE, -2); endTime.roll(Calendar.DATE, -1); System.out.println("StartTime: " + dateFormat.format(startTime.getTime())); System.out.println("EndTime: " + dateFormat.format(endTime.getTime())); // ######################################################### // =================================================================================== // ResourcePool Performance Counters Collect // =================================================================================== // -------------------------------------------------------------- // Build the PerfMetrics from the Host Performance Counters // -------------------------------------------------------------- PerfMetricId[] arrayOfPerfMetricId = null; /*//from w ww . j a va 2 s . com HashMap<Integer,PerfCounterInfo> mapPerf=performance.getMapOfPerfCounterInfoByIdByVC().get(hostName); System.out.println("Nb PerfCounterInfo: "+mapPerf.size()); PerfMetricId perfMetricId=null; ArrayList<PerfMetricId> listOfPerfMetricIds=new ArrayList<PerfMetricId>(); for (Map.Entry<Integer,PerfCounterInfo> entry:mapPerf.entrySet()) { perfMetricId=new PerfMetricId(); perfMetricId.setCounterId(entry.getKey()); perfMetricId.setInstance("*"); listOfPerfMetricIds.add(perfMetricId); } System.out.println("Nb PerfMetric: "+listOfPerfMetricIds.size()); if (!listOfPerfMetricIds.isEmpty()) { arrayOfPerfMetricId=(listOfPerfMetricIds.toArray(new PerfMetricId[listOfPerfMetricIds.size()])); } */ // -------------------------------------------------------------- // Build the PerfMetrics from the Host Performance Counters // -------------------------------------------------------------- HashMap<String, String> mapOfInstanceByCounterName = new HashMap<String, String>(); mapOfInstanceByCounterName.put("cpu.cpuentitlement.latest", ""); mapOfInstanceByCounterName.put("cpu.usagemhz.average", ""); mapOfInstanceByCounterName.put("mem.consumed.average", ""); mapOfInstanceByCounterName.put("mem.mementitlement.latest", ""); mapOfInstanceByCounterName.put("mem.overhead.average", ""); mapOfInstanceByCounterName.put("mem.vmmemctl.average", ""); //PerfMetricId[] arrayOfPerfMetricId=performance.getPerfMetric(this.getResourcePoolPerformanceCounters()); arrayOfPerfMetricId = performance.getPerfMetric(mapOfInstanceByCounterName); // -------------------------------------------------------------- // Build the PerfQuerySpecs from the Host PerfMetrics // -------------------------------------------------------------- int refreshRate = 300; PerfQuerySpec[] arrayOfPerfQuerySpecs = performance.getQueryPerfSpec(listOfTreenodes, arrayOfPerfMetricId, null, null, refreshRate); //PerfQuerySpec[] arrayOfPerfQuerySpecs=performance.getQueryPerfSpec(listOfTreenodes, arrayOfPerfMetricId, startTime, endTime, refreshRate); // -------------------------------------------------------------- // Retrieve the Performance Counter Values // -------------------------------------------------------------- ArrayList<PerfMetric> listOfPerfMetrics = null; ArrayList<PerfResult> listOfPerfResults = null; listOfPerfResults = performance.getPerf(arrayOfPerfQuerySpecs); System.out.println("listOfPerfResults: " + listOfPerfResults.size()); if (!listOfPerfResults.isEmpty()) { System.out.println("\n\n\n########## PerfResult ##########"); for (PerfResult perfResult : listOfPerfResults) { System.out.println("- Sampling Interval: " + perfResult.getSamplingRate()); System.out.println("- Sampling Period: " + perfResult.getSamplingPeriod()); System.out.println("- Entity: " + perfResult.getEntity().getName() + " / " + perfResult.getEntity().getMor().get_value() + " / " + perfResult.getEntity().getMor().getType()); listOfPerfMetrics = perfResult.getListOfPerfMetrics(); if (!listOfPerfMetrics.isEmpty()) { System.out.println("- Metrics:"); for (PerfMetric perfMetric : listOfPerfMetrics) { System.out.println( " - Counter: " + perfMetric.getCounterName() + " / " + perfMetric.getInstance()); System.out.println(" - Values: " + perfMetric.getValues()); } } System.out.println(""); } } // =================================================================================== // Destroy the VC connection // =================================================================================== VMware.delete(hostName); }
From source file:net.siveo.virtualization.vmware.Main.java
public void getDatastorePerf() throws VMwareException { // ========================================================================================= // Cration de la connexion au VirtualCenter // ========================================================================================= //String hostName="192.168.101.79"; //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L); //String hostName="vsphere-4-1"; //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L); String hostName = "10.251.5.14"; VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L); //String hostName="192.168.101.179"; //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L); WSManager wsManager = WSManager.getInstance(); WS ws = wsManager.getWS(hostName);/*from w ww.j a v a 2 s .co m*/ // ========================================================================================= // Initialize Variables // ========================================================================================= // Initialize the Performance Engine PerformanceManager performanceManager = PerformanceManager.getInstance(); performanceManager.init(hostName); DataStoreManager dataStoreManager = DataStoreManager.getInstance(); //Datastore datastore=dataStoreManager.getDatastoreByName("VCE-AMP-2", hostName); Datastore datastore = dataStoreManager.getDatastoreByName("SIVEO_ADMIN", hostName); System.out.println("DataStore: " + datastore.getMor().get_value()); // Get the Performance Counters PerfMetricId[] arrayOfPerfMetricIds = null; PerfQuerySpec[] arrayOfPerfQuerySpecs = null; DataStoreManager dsManager = DataStoreManager.getInstance(); HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager .getMapOfPerfCounterInfoByIdByVC().get(hostName); // ========================================================================================= // Get Datastore Performance Counters // ========================================================================================= SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS"); Calendar curTime = null; try { curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance()); } catch (RuntimeFault e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("curTime: "+curTime); //System.out.println("curTime: "+curTime.getTime()); //System.out.println("curTime timeZone: "+curTime.getTimeZone()); //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName()); //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID()); //System.out.println("curTime lenient: "+curTime.isLenient()); Calendar startTime = (Calendar) curTime.clone(); //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1); startTime.set(Calendar.HOUR_OF_DAY, 23); startTime.set(Calendar.MINUTE, 30); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); Calendar endTime = (Calendar) curTime.clone(); endTime.set(Calendar.HOUR_OF_DAY, 23); endTime.set(Calendar.MINUTE, 59); endTime.set(Calendar.SECOND, 59); endTime.set(Calendar.MILLISECOND, 00); endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1); startTime.roll(Calendar.DATE, -2); endTime.roll(Calendar.DATE, -1); //System.out.println("Ecart entre dbut et fin: "+(endTime.getTime().getTime()-startTime.getTime().getTime())); for (String counterName : this.getDatastorePerformanceCountersName()) { System.out.println("Counter: " + counterName); } arrayOfPerfMetricIds = performanceManager .getPerfMetricFromCounterNames(this.getDatastorePerformanceCountersName(), false, hostName); arrayOfPerfQuerySpecs = performanceManager.getDSQueryPerfSpec(dsManager.getAllDatastore(hostName), arrayOfPerfMetricIds, startTime, endTime); PerfCounterInfo perfCounterInfo = null; for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) { if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) { perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId()); System.out.println("Metric: " + perfMetricId.getCounterId() + "/" + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey() + "." + perfCounterInfo.getRollupType().name()); } } System.out.println("StartTime: " + dateFormat.format(startTime.getTime())); System.out.println("EndTime: " + dateFormat.format(endTime.getTime())); performanceManager.getPerfDS(hostName, arrayOfPerfQuerySpecs); // ========================================================================================= // Destruction de la connexion au VirtualCenter // ========================================================================================= VMware.delete(hostName); }
From source file:net.siveo.virtualization.vmware.Main.java
public void getDatacenterPerf_() throws VMwareException { // ========================================================================================= // Cration de la connexion au VirtualCenter // ========================================================================================= //String hostName="192.168.101.79"; //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L); //String hostName="vsphere-4-1"; //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L); String hostName = "10.251.5.14"; VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L); //String hostName="192.168.101.179"; //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L); WSManager wsManager = WSManager.getInstance(); WS ws = wsManager.getWS(hostName);//from w w w .j ava2 s . c om // ========================================================================================= // Construction des dates de Dpart de Fin pour la collecte des statistiques // ========================================================================================= SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS"); Calendar curTime = null; try { curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance()); } catch (RuntimeFault e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("curTime: "+curTime); //System.out.println("curTime: "+curTime.getTime()); //System.out.println("curTime timeZone: "+curTime.getTimeZone()); //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName()); //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID()); //System.out.println("curTime lenient: "+curTime.isLenient()); Calendar startTime = (Calendar) curTime.clone(); //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1); startTime.set(Calendar.HOUR_OF_DAY, 23); startTime.set(Calendar.MINUTE, 30); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); Calendar endTime = (Calendar) curTime.clone(); endTime.set(Calendar.HOUR_OF_DAY, 23); endTime.set(Calendar.MINUTE, 59); endTime.set(Calendar.SECOND, 59); endTime.set(Calendar.MILLISECOND, 00); endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1); startTime.roll(Calendar.DATE, -2); endTime.roll(Calendar.DATE, -1); System.out.println("StartTime: " + dateFormat.format(startTime.getTime())); System.out.println("EndTime: " + dateFormat.format(endTime.getTime())); // ========================================================================================= // // ========================================================================================= ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>(); DatacenterManager datacenterManager = DatacenterManager.getInstance(); Datacenter datacenter = datacenterManager.getDatacenterByName("RISC_POC", hostName); listOfTreeNodes.add(datacenter); System.out.println("Datacenter: " + datacenter.getMor().get_value()); // Initialize the Performance Engine PerformanceManager performanceManager = PerformanceManager.getInstance(); performanceManager.init(hostName); // ========================================================================================= // // ========================================================================================= //PerfMetricId[] arrOfPerfMetricIds=null; //arrOfPerfMetricIds=performanceManager.getAvailablePerfCounter(datacenter, null, null, 300); // Get the Performance Counters PerfMetricId[] arrayOfPerfMetricIds = null; PerfQuerySpec[] arrayOfPerfQuerySpecs = null; HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager .getMapOfPerfCounterInfoByIdByVC().get(hostName); arrayOfPerfMetricIds = performanceManager .getPerfMetricFromCounterNames(this.getDatacenterPerformanceCounters(), false, hostName); arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds, startTime, endTime, 300); /* PerfCounterInfo perfCounterInfo=null; for (PerfMetricId perfMetricId:arrayOfPerfMetricIds) { if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) { perfCounterInfo=mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId()); System.out.println("Metric: "+perfMetricId.getCounterId()+"/"+perfCounterInfo.getGroupInfo().getKey()+"."+perfCounterInfo.getNameInfo().getKey()+"."+perfCounterInfo.getRollupType().name()); } } */ performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs); // ========================================================================================= // Destruction de la connexion au VirtualCenter // ========================================================================================= VMware.delete(hostName); }
From source file:net.siveo.virtualization.vmware.Main.java
public void getClusterPerf() throws VMwareException { // ========================================================================================= // Cration de la connexion au VirtualCenter // ========================================================================================= //String hostName="192.168.101.79"; //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L); //String hostName="vsphere-4-1"; //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L); String hostName = "10.251.5.14"; VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L); //String hostName="192.168.101.179"; //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L); WSManager wsManager = WSManager.getInstance(); WS ws = wsManager.getWS(hostName);// www . j a v a2 s.co m // ========================================================================================= // Construction des dates de Dpart de Fin pour la collecte des statistiques // ========================================================================================= SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS"); Calendar curTime = null; try { curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance()); } catch (RuntimeFault e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("curTime: "+curTime); //System.out.println("curTime: "+curTime.getTime()); //System.out.println("curTime timeZone: "+curTime.getTimeZone()); //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName()); //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID()); //System.out.println("curTime lenient: "+curTime.isLenient()); Calendar startTime = (Calendar) curTime.clone(); //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1); startTime.set(Calendar.HOUR_OF_DAY, 23); startTime.set(Calendar.MINUTE, 30); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); Calendar endTime = (Calendar) curTime.clone(); endTime.set(Calendar.HOUR_OF_DAY, 23); endTime.set(Calendar.MINUTE, 59); endTime.set(Calendar.SECOND, 59); endTime.set(Calendar.MILLISECOND, 00); endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1); startTime.roll(Calendar.DATE, -2); endTime.roll(Calendar.DATE, -1); System.out.println("StartTime: " + dateFormat.format(startTime.getTime())); System.out.println("EndTime: " + dateFormat.format(endTime.getTime())); // ========================================================================================= // // ========================================================================================= ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>(); ResourceManager resourceManager = ResourceManager.getInstance(); ClusterComputeResource cluster = resourceManager.getClusterComputeResourceByName("SIVEO", hostName); listOfTreeNodes.add(cluster); System.out.println("Cluster: " + cluster.getMor().get_value()); // Initialize the Performance Engine PerformanceManager performanceManager = PerformanceManager.getInstance(); performanceManager.init(hostName); // ========================================================================================= // // ========================================================================================= //PerfMetricId[] arrOfPerfMetricIds=null; //arrOfPerfMetricIds=performanceManager.getAvailablePerfCounter(datacenter, null, null, 300); performanceManager.getAvailablePerfCounter(cluster, null, null, 300); // Get the Performance Counters PerfMetricId[] arrayOfPerfMetricIds = null; PerfQuerySpec[] arrayOfPerfQuerySpecs = null; HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager .getMapOfPerfCounterInfoByIdByVC().get(hostName); arrayOfPerfMetricIds = performanceManager .getPerfMetricFromCounterNames(this.getClusterPerformanceCounters(), true, hostName); arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds, startTime, endTime, 300); /* PerfCounterInfo perfCounterInfo=null; for (PerfMetricId perfMetricId:arrayOfPerfMetricIds) { if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) { perfCounterInfo=mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId()); System.out.println("Metric: "+perfMetricId.getCounterId()+"/"+perfCounterInfo.getGroupInfo().getKey()+"."+perfCounterInfo.getNameInfo().getKey()+"."+perfCounterInfo.getRollupType().name()); } } */ performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs); // ========================================================================================= // Destruction de la connexion au VirtualCenter // ========================================================================================= VMware.delete(hostName); }
From source file:net.siveo.virtualization.vmware.Main.java
public void getResourcePoolPerf() throws VMwareException { // ========================================================================================= // Cration de la connexion au VirtualCenter // ========================================================================================= //String hostName="192.168.101.79"; //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L); //String hostName="vsphere-4-1"; //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L); String hostName = "10.251.5.14"; VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L); //String hostName="192.168.101.179"; //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L); WSManager wsManager = WSManager.getInstance(); WS ws = wsManager.getWS(hostName);/* ww w . j a v a 2 s . co m*/ // ========================================================================================= // // ========================================================================================= SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS"); Calendar curTime = null; try { curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance()); } catch (RuntimeFault e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("curTime: "+curTime); //System.out.println("curTime: "+curTime.getTime()); //System.out.println("curTime timeZone: "+curTime.getTimeZone()); //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName()); //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID()); //System.out.println("curTime lenient: "+curTime.isLenient()); Calendar startTime = (Calendar) curTime.clone(); //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1); startTime.set(Calendar.HOUR_OF_DAY, 23); startTime.set(Calendar.MINUTE, 30); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); Calendar endTime = (Calendar) curTime.clone(); endTime.set(Calendar.HOUR_OF_DAY, 23); endTime.set(Calendar.MINUTE, 59); endTime.set(Calendar.SECOND, 59); endTime.set(Calendar.MILLISECOND, 00); endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1); startTime.roll(Calendar.DATE, -2); endTime.roll(Calendar.DATE, -1); System.out.println("StartTime: " + dateFormat.format(startTime.getTime())); System.out.println("EndTime: " + dateFormat.format(endTime.getTime())); // ========================================================================================= // // ========================================================================================= ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>(); ArrayList<ResourcePool> listOfResourcePools = new ArrayList<ResourcePool>(); ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance(); ResourcePool resourcePool = resourcePoolManager.getResourcePoolByName(hostName, "ResourcePool1_1"); //listOfResourcePools.add(resourcePool); listOfTreeNodes.add(resourcePool); System.out.println("ResourcePool: " + resourcePool.getMor().get_value()); // Initialize the Performance Engine PerformanceManager performanceManager = PerformanceManager.getInstance(); performanceManager.init(hostName); // ========================================================================================= // // ========================================================================================= PerfMetricId[] arrOfPerfMetricIds = null; arrOfPerfMetricIds = performanceManager.getAvailablePerfCounter(resourcePool, null, null, 300); // Get the Performance Counters PerfMetricId[] arrayOfPerfMetricIds = null; PerfQuerySpec[] arrayOfPerfQuerySpecs = null; HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager .getMapOfPerfCounterInfoByIdByVC().get(hostName); arrayOfPerfMetricIds = performanceManager .getPerfMetricFromCounterNames(this.getResourcePoolPerformanceCounters(), false, hostName); ////arrayOfPerfQuerySpecs=performanceManager.getResourcePoolQueryPerfSpec(listOfResourcePools,arrayOfPerfMetricIds,startTime,endTime); //arrayOfPerfQuerySpecs=performanceManager.getQueryPerfSpec(listOfTreeNodes,arrayOfPerfMetricIds,startTime,endTime,1800); arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds, null, null, 1800); PerfCounterInfo perfCounterInfo = null; for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) { if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) { perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId()); System.out.println("Metric: " + perfMetricId.getCounterId() + "/" + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey() + "." + perfCounterInfo.getRollupType().name()); } } performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs); // ========================================================================================= // Destruction de la connexion au VirtualCenter // ========================================================================================= VMware.delete(hostName); }
From source file:net.siveo.virtualization.vmware.Main.java
public void performanceCounter() throws VMwareException { //String hostName="vsphere-4-1"; //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L,1000L); String hostName = "10.0.12.6"; VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L); //String hostName="10.251.5.14"; //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L); WSManager wsManager = WSManager.getInstance(); WS ws = wsManager.getWS(hostName);//w w w . j av a 2s. c o m PerformanceManager performanceManager = PerformanceManager.getInstance(); Calendar curTime = null; try { curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance()); } catch (RuntimeFault e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //System.out.println("curTime: "+curTime); //System.out.println("curTime: "+curTime.getTime()); //System.out.println("curTime timeZone: "+curTime.getTimeZone()); //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName()); //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID()); //System.out.println("curTime lenient: "+curTime.isLenient()); Calendar startTime = (Calendar) curTime.clone(); //startTime.roll(Calendar.DATE, -1); //startTime.roll(Calendar.DATE, -4); //startTime.add(Calendar.HOUR_OF_DAY, -30); //startTime.add(Calendar.MINUTE, -70); //startTime.add(Calendar.MINUTE, -60); startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1); /* startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1); startTime.set(Calendar.MINUTE, 00); startTime.set(Calendar.SECOND, 00); startTime.set(Calendar.MILLISECOND, 00); //startTime.s //startTime.set(Calendar.DAY_OF_MONTH,6); //startTime.set(Calendar.MONTH,5); */ //System.out.println("StartTime timezone: "+startTime.getTimeZone()); //System.out.println("StartTime timezone: "+startTime.getTimeZone().getDisplayName()); //System.out.println("StartTime timezone id: "+startTime.getTimeZone().getID()); //System.out.println("StartTime lenient: "+startTime.isLenient()); Calendar endTime = (Calendar) curTime.clone(); //endTime.roll(Calendar.DATE, -1); //endTime.roll(Calendar.DATE, -3); /* //endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY)-1); endTime.set(Calendar.MINUTE, 00); endTime.set(Calendar.SECOND, 00); endTime.set(Calendar.MILLISECOND, 00); //endTime.set(Calendar.DAY_OF_MONTH,6); //endTime.set(Calendar.MONTH,5); */ //System.out.println("StartTime: "+startTime.toString()); //System.out.println("EndTime: "+endTime); ArrayList<TreeNode> listOfTreeNode = new ArrayList<TreeNode>(); HostManager hostManager = HostManager.getInstance(); Host host = hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName); //listOfTreeNode.add(host); //host=hostManager.getHostByName("tc3-cli-esx02.hosts.vdc", hostName); //listOfTreeNode.add(host); DataStoreManager dataStoreManager = DataStoreManager.getInstance(); //Datastore ds=dataStoreManager.getDatastoreByID("datastore-1194", hostName); Datastore ds = dataStoreManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Grodaf", hostName); DatacenterManager datacenterManager = DatacenterManager.getInstance(); Datacenter dc = datacenterManager.getDatacenterByName("Siveo", hostName); VMManager vmManager = VMManager.getInstance(); //VirtualMachine vm=vmManager.getVmByName(hostName, "Tevst_VM_Grodaf"); VirtualMachine vm = vmManager.getVmByName(hostName, "TestVM"); startTime.roll(Calendar.DATE, -1); //endTime.roll(Calendar.DATE, -1); System.out.println( "Ecart entre dbut et fin: " + (endTime.getTime().getTime() - startTime.getTime().getTime())); ResourceManager resourceManager = ResourceManager.getInstance(); ClusterComputeResource cluster = resourceManager.getClusterComputeResourceByName("POC-Siveo", hostName); ManagedObjectReference mor = new ManagedObjectReference(); mor.setType("ClusterComputeResource"); mor.set_value("domain-c1066"); ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance(); ResourcePool rs = resourcePoolManager.getResourcePoolByName(hostName, "TestResourcePool"); PerfProviderSummary perfProviderSummary = performanceManager.buildPerformance(rs); System.out.println("Historical Statistics: " + perfProviderSummary.isSummarySupported()); System.out.println("Realtime Statistics: " + perfProviderSummary.isCurrentSupported()); System.out.println("Refresh Rate: " + perfProviderSummary.getRefreshRate()); ArrayList<String> listOfClusterCounters = new ArrayList<String>(); listOfClusterCounters.add("clusterServices.effectivecpu.average"); listOfClusterCounters.add("clusterServices.effectivemem.average"); listOfClusterCounters.add("clusterServices.failover.latest"); listOfTreeNode.add(cluster); //performanceManager.getPerformanceDS(listOfTreeNode, PerformanceMetric.CLUSTER_COUNTERS, startTime, null,300); performanceManager.getPerformance(listOfTreeNode, listOfClusterCounters, null, null, 300); //performanceManager.getPerformance(ds,null, null, null, null,300); performanceManager.getPerformance(rs, null, null, null, null, 300); //performanceManager.getPerformance(cluster,"clusterServices.effectivecpu.average", null, null, null,300); //performanceManager.getPerformance(cluster,"clusterServices.effectivemem.average", null, null, null,300); //performanceManager.getPerformance(cluster,"clusterServices.cpufairness.latest", null, null, null,300); //performanceManager.getPerformance(cluster,"clusterServices.failover.latest", null, null, null,300); //performanceManager.getPerformance(cluster,"clusterServices.memfairness.latest", null, null, null,300); //performanceManager.getPerformance(ds,"disk.used.latest", null, startTime, null,300); //performanceManager.getPerformance(ds,"disk.capacity.latest", null, startTime, null); //performanceManager.getPerformance(ds,null, null, startTime, endTime); /* HashMap<Integer,Counter> listOfCounters=performanceManager.getAllCounters(hostName); String counterName=null; String counterUpperName=null; for (Map.Entry<Integer,Counter> counterbyId:listOfCounters.entrySet()) { counterName=counterbyId.getValue().getGroupKey()+"."+counterbyId.getValue().getNameKey()+"."+counterbyId.getValue().getRollupType(); counterUpperName=counterName.toUpperCase(); counterUpperName=counterUpperName.replace(".", "_"); System.out.println("public static String "+ counterUpperName+"="+"\""+counterName+"\";"); } */ /* ArrayList<Counter> listOfCounters=performanceManager.getCountersByLevel(hostName, 4); for (Counter counter:listOfCounters) { System.out.println(counter.getGroupKey()+"."+counter.getNameKey()+"."+counter.getRollupType()+";"+ counter.getGroupKey()+";"+counter.getGroupName()+";"+ counter.getId()+";"+counter.getNameKey()+";"+counter.getName()+";"+counter.getDescription()+ ";"+counter.getRollupType()+";"+counter.getStatisticsType()+";"+counter.getUnitKey()+";"+counter.getUnit()+ ";"+counter.getUnitDescription()); } HashMap<String, HistoricalInterval> mapOfHistoInterval=performanceManager.getMapOfHistoricalIntervalByName(); for (Map.Entry<String, HistoricalInterval> histo:mapOfHistoInterval.entrySet()) { System.out.println("- Name: "+histo.getKey()+" / Sampling Period: "+histo.getValue().getSamplingPeriod()); } */ //VMManager vmManager=VMManager.getInstance(); //VirtualMachine vm=vmManager.getVmByName(hostName, "Test_VM_Grodaf"); //ResourceManager resourceManager=ResourceManager.getInstance(); //ClusterComputeResource clusterComputeResource=resourceManager.g //HostManager hostManager=HostManager.getInstance(); //Host host=hostManager.getHostByName("esx01.siveo.net", hostName); //Host host=hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName); //tc3-cli-esx01.hosts.vdc ////performanceManager.getPerformance(host, null, null,startTime,endTime); //performanceManager.getPerformance(host, null, null,null,null); //performanceManager.getPerformance(vm, null, null,null,null); //performanceManager.getPerformance(host, null, null); //performanceManager.getPerformance(host, "cpu.usagemhz.maximum", null); //performanceManager.getPerformance(host, "disk.usage.maximum", null); /* PerformanceDescription performanceDescription=null; performanceDescription=(PerformanceDescription)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"description"}); if (performanceDescription!=null) { System.out.println("***** Counter Type *****"); for (ElementDescription elementDescription:performanceDescription.getCounterType()) { System.out.println("- Key: "+elementDescription.getKey()); System.out.println("- Label: "+elementDescription.getLabel()); System.out.println("- Summary: "+elementDescription.getSummary()); System.out.println(""); } System.out.println("***** Statistic Type *****"); for (ElementDescription elementDescription:performanceDescription.getStatsType()) { System.out.println("- Key: "+elementDescription.getKey()); System.out.println("- Label: "+elementDescription.getLabel()); System.out.println("- Summary: "+elementDescription.getSummary()); System.out.println(""); } } */ /* ArrayOfPerfInterval arrayOfPerfInterval=null; arrayOfPerfInterval=(ArrayOfPerfInterval)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"historicalInterval"}); if (arrayOfPerfInterval!=null) { System.out.println("***** Performance Interval *****"); for (PerfInterval perfInterval:arrayOfPerfInterval.getPerfInterval()) { System.out.println("-Key: "+perfInterval.getKey()); System.out.println("-Name: "+perfInterval.getName()); System.out.println("-Level: "+perfInterval.getLevel()); System.out.println("-Length: "+perfInterval.getLength()); System.out.println("-Sampling Period: "+perfInterval.getSamplingPeriod()); System.out.println(""); } } */ /* HashMap<Integer, Counter> mapOfAllCounters=performanceManager.getAllCounters(hostName); Counter counter=null; for (Map.Entry<Integer, Counter> counterbyID:mapOfAllCounters.entrySet()) { counter=counterbyID.getValue(); System.out.println(counterbyID.getKey()+";"+counter.getGroupKey()+"."+counter.getNameKey()+"."+counter.getRollupType()+";"+counter.getLevel()+";"+counter.getName()+";"+counter.getDescription()+";"+counter.getStatisticsType()+";"+counter.getUnitKey()+";"+counter.getUnit()+";"+counter.getUnitDescription()); } */ // HostManager hostManager=HostManager.getInstance(); // Host host=hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName); // VMManager vmManager=VMManager.getInstance(); // VirtualMachine vm=vmManager.getVmByName(hostName, "ESSAI2"); // HashMap<Integer, Counter> mapOfCOunterByID=null; // mapOfCOunterByID=performanceManager.getAllCounters(hostName); /* System.out.println("***** Performance Counters *****\n"); for (Map.Entry<Integer, Counter> counterByID:mapOfCOunterByID.entrySet()) { System.out.println("-ID: "+counterByID.getValue().getId()); System.out.println("-Group Key: "+counterByID.getValue().getGroupKey()); System.out.println("-Group Name: "+counterByID.getValue().getGroupName()); System.out.println("-Level: "+counterByID.getValue().getLevel()); System.out.println("-Name Key: "+counterByID.getValue().getNameKey()); System.out.println("-Name: "+counterByID.getValue().getName()); System.out.println("-Description: "+counterByID.getValue().getDescription()); System.out.println("-Rollup Type: "+counterByID.getValue().getRollupType()); System.out.println("-Statistics Type: "+counterByID.getValue().getStatisticsType()); System.out.println("-Unit Key: "+counterByID.getValue().getUnitKey()); System.out.println("-Unit: "+counterByID.getValue().getUnit()); System.out.println("-Unit Description: "+counterByID.getValue().getUnitDescription()); System.out.println(""); } */ // System.out.println("***** Performance Provider *****\n"); // performanceManager.getPerformanceProvider(vm); //performanceManager.getPerformanceProvider(vm); // System.out.println("***** Available Performance Counters *****\n"); // performanceManager.getAvailablePerfCounter(vm); //System.out.println("***** Available Performance Counters *****\n"); //performanceManager.getAvailablePerfCounter(host); //System.out.println("\n***** Performance *****\n"); //performanceManager.getPerformance(host); /* ArrayOfPerfCounterInfo arrOfPerfCounterInfo=null; PerfCounterInfo[] counterInfoArr=null; arrOfPerfCounterInfo=(ArrayOfPerfCounterInfo)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"perfCounter"}); if (arrOfPerfCounterInfo!=null && arrOfPerfCounterInfo.getPerfCounterInfo() !=null && arrOfPerfCounterInfo.getPerfCounterInfo().length>0) { counterInfoArr=arrOfPerfCounterInfo.getPerfCounterInfo(); int nb=1; String level=null; for (PerfCounterInfo perfcounterInfo:counterInfoArr) { if (perfcounterInfo.getLevel()!=null) { level=String.valueOf(perfcounterInfo.getLevel()); //System.out.println("Level: "); //System.out.println("- value: "+perfcounterInfo.getLevel()); } else level="N/A"; System.out.println(perfcounterInfo.getGroupInfo().getKey()+";"+perfcounterInfo.getGroupInfo().getLabel()+";"+perfcounterInfo.getGroupInfo().getSummary()+";"+ perfcounterInfo.getKey()+";"+level+";"+perfcounterInfo.getNameInfo().getKey()+";"+perfcounterInfo.getNameInfo().getLabel()+";"+perfcounterInfo.getNameInfo().getSummary()+ ";"+perfcounterInfo.getRollupType().name()+";"+perfcounterInfo.getStatsType().name()+";"+perfcounterInfo.getUnitInfo().getKey()+";"+perfcounterInfo.getUnitInfo().getLabel()+ ";"+perfcounterInfo.getUnitInfo().getSummary() ); // System.out.println("\nN"+nb++); // System.out.println("GroupInfo"); // System.out.println("- Key: "+perfcounterInfo.getGroupInfo().getKey()); // System.out.println("- Label : "+perfcounterInfo.getGroupInfo().getLabel()); // System.out.println("- Summary: "+perfcounterInfo.getGroupInfo().getSummary()); // System.out.println("Key: "); // System.out.println("- value: "+perfcounterInfo.getKey()); // if (perfcounterInfo.getLevel()!=null) // { // level=String.valueOf(perfcounterInfo.getLevel()); // System.out.println("Level: "); // System.out.println("- value: "+perfcounterInfo.getLevel()); // } // // System.out.println("NameInfo:"); // System.out.println("- Key: "+perfcounterInfo.getNameInfo().getKey()); // System.out.println("- Label : "+perfcounterInfo.getNameInfo().getLabel()); // System.out.println("- Summary: "+perfcounterInfo.getNameInfo().getSummary()); // // System.out.println("RollupType: "); // System.out.println("- value: "+perfcounterInfo.getRollupType().toString()); // // System.out.println("StatsType: "); // System.out.println("- value: "+perfcounterInfo.getStatsType().toString()); // // System.out.println("unitInfo: "); // System.out.println("- Key: "+perfcounterInfo.getUnitInfo().getKey()); // System.out.println("- Label : "+perfcounterInfo.getUnitInfo().getLabel()); // System.out.println("- Summary: "+perfcounterInfo.getUnitInfo().getSummary()); } } */ //PerformanceManagerUnit VMware.delete(hostName); }