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

项目:photon-model    文件:StatsClient.java   
/**
 * Makes a PerfMetricId by looking up the counterId for the given group/name/rollupType/... params.
 *
 * https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.PerformanceManager.MetricId.html
 *
 * See <a href="https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/cpu_counters.html">cpu counters</a>
 * See <a href="https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/memory_counters.html>memory counters</a>
 * See <a href="https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/network_counters.html">network counters</a>
 *
 * @param group
 * @param name
 * @param rollupType
 * @return null if a PerfCoutner cannot be found for the given params
 */
private PerfMetricId findMetricId(String group, String name, PerfStatsType type,
        PerformanceManagerUnit unit, PerfSummaryType rollupType) {
    PerfMetricId res = new PerfMetricId();
    PerfCounterInfo counter = this.perfCounterLookup
            .getCounter(name, group, type, rollupType, unit);

    if (counter == null) {
        String msg = String
                .format("Cannot find metric for %s/%s/%s/%s/%s", group, name, type,
                        rollupType.value(),
                        unit.value());
        logger.warning(msg);
        throw new IllegalArgumentException(msg);
    }
    res.setCounterId(counter.getKey());
    res.setInstance("");
    return res;
}
项目:cloudstack    文件:PerfCounterInfoMapper.java   
public PerfCounterInfo[] lookup(String groupName, String counterName, PerfSummaryType rollupType) {
    assert (groupName != null);
    assert (counterName != null);

    Map<String, List<PerfCounterInfo>> groupMap = _mapCounterInfos.get(groupName);
    if (groupMap == null)
        return null;

    List<PerfCounterInfo> counterInfoList = groupMap.get(counterName);
    if (counterInfoList == null)
        return null;

    if (rollupType == null) {
        return counterInfoList.toArray(new PerfCounterInfo[0]);
    }

    for (PerfCounterInfo info : counterInfoList) {
        if (info.getRollupType() == rollupType)
            return new PerfCounterInfo[] {info};
    }

    return null;
}
项目:photon-model    文件:DailyAggregator.java   
@Override
public ServiceStat createStat(PerfCounterInfo pc, List<PerfSampleInfo> infos,
        List<Long> values) {

    if (infos == null || infos.isEmpty()) {
        return null;
    }

    ServiceStat res = new ServiceStat();

    res.name = this.name;
    res.unit = this.unit;

    PerfSampleInfo info = null;
    double converted = 0;

    int intervalLengthMinutes = 5;
    res.timeSeriesStats = new TimeSeriesStats(24 * 60 / intervalLengthMinutes,
            intervalLengthMinutes * 60 * 1000,
            EnumSet.allOf(AggregationType.class));

    for (int i = 0; i < infos.size(); i++) {
        info = infos.get(i);
        Long value = values.get(i);

        converted = convertValue(value);
        res.timeSeriesStats.add(getSampleTimestampMicros(info), converted, converted);
    }

    res.sourceTimeMicrosUtc = res.lastUpdateMicrosUtc = getSampleTimestampMicros(info);
    res.latestValue = converted;
    return res;
}
项目:photon-model    文件:StatsClient.java   
/**
 * See <a href="https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.PerformanceManager.html#queryStats">queryStats method</a>
 * @param ctx
 * @return
 * @throws RuntimeFaultFaultMsg
 */
private List<ServiceStat> querySingleEntity(StatCollectionContext ctx)
        throws RuntimeFaultFaultMsg {
    List<PerfEntityMetricBase> metrics = getVimPort().queryPerf(PERF_MGR_MOREF,
            Collections.singletonList(ctx.getSpec()));

    List<ServiceStat> res = new ArrayList<>();

    if (metrics.isEmpty()) {
        // nothing fetched
        return Collections.emptyList();
    }

    // the metrics for the single entity
    PerfEntityMetric m = (PerfEntityMetric) metrics.get(0);

    for (PerfMetricSeries pms : m.getValue()) {
        PerfMetricId metricId = pms.getId();
        PerfMetricIntSeries series = (PerfMetricIntSeries) pms;
        SamplesAggregator factory = ctx.getFactory(metricId.getCounterId());

        PerfCounterInfo counter = this.perfCounterLookup
                .getCounterByKey(metricId.getCounterId());

        ServiceStat stat = factory.createStat(counter, m.getSampleInfo(), series.getValue());
        if (stat != null) {
            res.add(stat);
        }
    }

    return res;
}
项目:photon-model    文件:PerfCounterLookup.java   
public PerfCounterInfo getCounter(String name, String groupName, PerfStatsType type,
        PerfSummaryType rollupType,
        PerformanceManagerUnit unit) {
    for (PerfCounterInfo pci : this.counters) {
        if (pci.getNameInfo().getKey().equals(name) &&
                pci.getGroupInfo().getKey().equals(groupName) &&
                pci.getRollupType().equals(rollupType) &&
                pci.getStatsType().equals(type) &&
                pci.getUnitInfo().getKey().equals(unit.value())) {
            return pci;
        }
    }

    return null;
}
项目:photon-model    文件:PerfCounterLookup.java   
public PerfCounterInfo getCounterByKey(int key) {
    for (PerfCounterInfo pci : this.counters) {
        if (pci.getKey() == key) {
            return pci;
        }
    }

    return null;
}
项目:vijava    文件:PrintPerfMgr.java   
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();
}
项目:vijava    文件:PrintPerfMgr.java   
static void printPerfCounters(PerfCounterInfo[] pcis)
{
  for(int i=0; pcis!=null && i<pcis.length; i++)
  {
    System.out.println("\nKey:" + pcis[i].getKey());
    String perfCounter = pcis[i].getGroupInfo().getKey() + "."
        + pcis[i].getNameInfo().getKey() + "." 
        + pcis[i].getRollupType();
    System.out.println("PerfCounter:" + perfCounter);
    System.out.println("Level:" + pcis[i].getLevel());
    System.out.println("StatsType:" + pcis[i].getStatsType());
    System.out.println("UnitInfo:" 
        + pcis[i].getUnitInfo().getKey());
  }
}
项目:opennmszh    文件:VmwareViJavaAccess.java   
/**
 * This method retrieves the performance counters available.
 *
 * @return a map of performance counters
 */
public Map<Integer, PerfCounterInfo> getPerfCounterInfoMap() {
    if (m_perfCounterInfoMap == null) {
        m_perfCounterInfoMap = new HashMap<Integer, PerfCounterInfo>();

        PerfCounterInfo[] perfCounterInfos = getPerformanceManager().getPerfCounter();

        for (PerfCounterInfo perfCounterInfo : perfCounterInfos) {
            m_perfCounterInfoMap.put(perfCounterInfo.getKey(), perfCounterInfo);
        }
    }
    return m_perfCounterInfoMap;
}
项目:cloudstack    文件:PerfCounterInfoMapper.java   
public PerfCounterInfoMapper(PerfCounterInfo[] counterInfos) {
    if (counterInfos != null) {
        for (PerfCounterInfo counterInfo : counterInfos) {
            List<PerfCounterInfo> counterInfoList = getSafeCounterInfoList(counterInfo.getGroupInfo().getKey(), counterInfo.getNameInfo().getKey());
            counterInfoList.add(counterInfo);
        }
    }
}
项目:cloudstack    文件:PerfCounterInfoMapper.java   
public PerfCounterInfo lookupOne(String groupName, String counterName, PerfSummaryType rollupType) {
    PerfCounterInfo[] infos = lookup(groupName, counterName, rollupType);
    if (infos != null && infos.length > 0)
        return infos[0];

    return null;
}
项目:cloudstack    文件:PerfCounterInfoMapper.java   
private Map<String, List<PerfCounterInfo>> getSafeGroupMap(String groupName) {
    Map<String, List<PerfCounterInfo>> groupMap = _mapCounterInfos.get(groupName);
    if (groupMap == null) {
        groupMap = new HashMap<String, List<PerfCounterInfo>>();
        _mapCounterInfos.put(groupName, groupMap);
    }
    return groupMap;
}
项目:cloudstack    文件:PerfCounterInfoMapper.java   
private List<PerfCounterInfo> getSafeCounterInfoList(String groupName, String counterName) {
    Map<String, List<PerfCounterInfo>> groupMap = getSafeGroupMap(groupName);
    assert (groupMap != null);

    List<PerfCounterInfo> counterInfoList = groupMap.get(counterName);
    if (counterInfoList == null) {
        counterInfoList = new ArrayList<PerfCounterInfo>();
        groupMap.put(counterName, counterInfoList);
    }
    return counterInfoList;
}
项目:cloudstack    文件:PerfManagerMO.java   
public List<PerfCounterInfo> queryPerfCounter(int[] counterId) throws Exception {
    List<Integer> counterArr = new ArrayList<Integer>();
    if (counterId != null) {
        for (int i = 0; i < counterId.length; i++) {
            counterArr.add(counterId[i]);
        }
    }
    return _context.getService().queryPerfCounter(_mor, counterArr);
}
项目:photon-model    文件:PerfCounterLookup.java   
public PerfCounterLookup(List<PerfCounterInfo> counters) {
    this.counters = counters;
}
项目:opennmszh    文件:VmwareViJavaAccess.java   
/**
 * This method queries performance values for a given managed entity.
 *
 * @param managedEntity the managed entity to query
 * @return the perfomance values
 * @throws RemoteException
 */
public VmwarePerformanceValues queryPerformanceValues(ManagedEntity managedEntity) throws RemoteException {

    VmwarePerformanceValues vmwarePerformanceValues = new VmwarePerformanceValues();

    int refreshRate = getPerformanceManager().queryPerfProviderSummary(managedEntity).getRefreshRate();

    PerfQuerySpec perfQuerySpec = new PerfQuerySpec();
    perfQuerySpec.setEntity(managedEntity.getMOR());
    perfQuerySpec.setMaxSample(Integer.valueOf(1));

    perfQuerySpec.setIntervalId(refreshRate);

    PerfEntityMetricBase[] perfEntityMetricBases = getPerformanceManager().queryPerf(new PerfQuerySpec[]{perfQuerySpec});

    if (perfEntityMetricBases != null) {
        for (int i = 0; i < perfEntityMetricBases.length; i++) {
            PerfMetricSeries[] perfMetricSeries = ((PerfEntityMetric) perfEntityMetricBases[i]).getValue();

            for (int j = 0; perfMetricSeries != null && j < perfMetricSeries.length; j++) {

                if (perfMetricSeries[j] instanceof PerfMetricIntSeries) {
                    long[] longs = ((PerfMetricIntSeries) perfMetricSeries[j]).getValue();

                    if (longs.length == 1) {

                        PerfCounterInfo perfCounterInfo = getPerfCounterInfoMap().get(perfMetricSeries[j].getId().getCounterId());
                        String instance = perfMetricSeries[j].getId().getInstance();
                        String name = getHumanReadableName(perfCounterInfo);

                        if (instance != null && !"".equals(instance)) {
                            vmwarePerformanceValues.addValue(name, instance, longs[0]);
                        } else {
                            vmwarePerformanceValues.addValue(name, longs[0]);
                        }
                    }
                }
            }
        }
    }

    return vmwarePerformanceValues;
}
项目:cloudstack    文件:PerfManagerMO.java   
public List<PerfCounterInfo> queryPerfCounterByLevel(int level) throws Exception {
    return _context.getService().queryPerfCounterByLevel(_mor, level);
}
项目:cloudstack    文件:PerfManagerMO.java   
public List<PerfCounterInfo> getCounterInfo() throws Exception {
    return _context.getVimClient().getDynamicProperty(_mor, "perfCounter");
}
项目:opennmszh    文件:VmwareViJavaAccess.java   
/**
 * Generates a human-readable name for a performance counter.
 *
 * @param perfCounterInfo the perfomance counter info object
 * @return a string-representation of the performance counter's name
 */
private String getHumanReadableName(PerfCounterInfo perfCounterInfo) {
    return perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey() + "." + perfCounterInfo.getRollupType().toString();
}
项目:photon-model    文件:SamplesAggregator.java   
ServiceStat createStat(PerfCounterInfo counter, List<PerfSampleInfo> infos, List<Long> data);
项目:jcloud-vsphere    文件:PerformanceManagerApi.java   
List<PerfCounterInfo> getPerfCounter();
项目:jcloud-vsphere    文件:PerformanceManagerApi.java   
List<PerfCounterInfo> queryPerfCounter(List<Integer> counterIds) throws RuntimeFault, RemoteException;
项目:jcloud-vsphere    文件:PerformanceManagerApi.java   
List<PerfCounterInfo> queryPerfCounterByLevel(int level) throws RuntimeFault, RemoteException;