Package org.hyperic.sigar

Examples of org.hyperic.sigar.CpuPerc


  }

  public static void getServerCpuInfo(Sigar sigar, ServerStatus status) {
    try {
      CpuInfo infos[] = sigar.getCpuInfoList();
      CpuPerc cpuList[] = sigar.getCpuPercList();
      double totalUse = 0L;
      for (int i = 0; i < infos.length; i++) {
        CpuPerc perc = cpuList[i];
        CpuInfoVo cpuInfo = new CpuInfoVo();
        cpuInfo.setId(infos[i].hashCode() + "");
        cpuInfo.setCacheSize(infos[i].getCacheSize());
        cpuInfo.setModel(infos[i].getModel());
        cpuInfo.setUsed(CpuPerc.format(perc.getCombined()));
        cpuInfo.setUsedOrigVal(perc.getCombined());
        cpuInfo.setIdle(CpuPerc.format(perc.getIdle()));
        cpuInfo.setTotalMHz(infos[i].getMhz());
        cpuInfo.setVendor(infos[i].getVendor());
        status.getCpuInfos().add(cpuInfo);
        totalUse += perc.getCombined();
      }
      String cpuu = CpuPerc.format(totalUse / status.getCpuInfos().size());
      cpuu = cpuu.substring(0,cpuu.length()-1);
      status.setCpuUsage(cpuu);
    } catch (Exception e) {
View Full Code Here


    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
        SystemInfo info = this.resourceContext.getSystemInformation();
        boolean isNative = info.isNative();
        Mem platformMemoryInfo = null;
        Swap platformSwapInfo = null;
        CpuPerc cpuPerc = null;
        try {
            cpuPerc = SigarAccess.getSigar().getCpuPerc();
        } catch (Exception e) {
            // probably native api is unavailable, but getCpuPerc might also have a problem; in either case, nothing we can do
        }
View Full Code Here

  private List<DataEntity> buildCpuInfo() {
    ArrayList<DataEntity> entities = new ArrayList<DataEntity>();

    try {
      CpuPerc cpuPerc = m_sigar.getCpuPerc();
      double system = cpuPerc.getSys();
      double iowait = cpuPerc.getWait();
      double nice = cpuPerc.getNice();
      double steal = cpuPerc.getStolen();
      double user = cpuPerc.getUser();
      double softirq = cpuPerc.getSoftIrq();
      double idle = cpuPerc.getIdle();
      double irq = cpuPerc.getIrq();
      Map<String, Double> values = new HashMap<String, Double>();

      values.put(buildSystemId("sysCpu"), system);
      values.put(buildSystemId("iowaitCpu"), iowait);
      values.put(buildSystemId("niceCpu"), nice);
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.CpuPerc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.