コード例 #1
0
 private void output(CpuPerc cpu) {
   println("User Time....." + CpuPerc.format(cpu.getUser())); // 用户使用率
   println("Sys Time......" + CpuPerc.format(cpu.getSys())); // 系统CPU使用率
   println("Idle Time....." + CpuPerc.format(cpu.getIdle())); // 当前空闲率
   println("Wait Time....." + CpuPerc.format(cpu.getWait())); // 当前等待率
   println("Nice Time....." + CpuPerc.format(cpu.getNice()));
   println("Combined......" + CpuPerc.format(cpu.getCombined())); // 总的使用率
   println("Irq Time......" + CpuPerc.format(cpu.getIrq()));
   println("");
 }
コード例 #2
0
 public static List<ServerInfoFormMap> cpuInfos(Sigar sigar) {
   List<ServerInfoFormMap> monitorMaps = new ArrayList<ServerInfoFormMap>();
   try {
     CpuPerc cpuList[] = sigar.getCpuPercList();
     for (CpuPerc cpuPerc : cpuList) {
       ServerInfoFormMap monitorMap = new ServerInfoFormMap();
       monitorMap.put("cpuUserUse", Math.round(cpuPerc.getUser() * 100)); // 用户使用率
       monitorMap.put("cpuSysUse", Math.round(cpuPerc.getSys() * 100)); // 系统使用率
       monitorMap.put("cpuWait", Math.round(cpuPerc.getWait() * 100)); // 当前等待率
       monitorMap.put("cpuFree", Math.round(cpuPerc.getIdle() * 100)); // 当前空闲率
       monitorMap.put("cpuTotal", Math.round(cpuPerc.getCombined() * 100)); // 总的使用率
       monitorMaps.add(monitorMap);
     }
   } catch (Exception e) {
   }
   return monitorMaps;
 }