long cacheSize = info.getCacheSize(); println("Vendor........." + info.getVendor()); println("Model.........." + info.getModel()); println("Mhz............" + info.getMhz()); println("Total CPUs....." + info.getTotalCores()); if ((info.getTotalCores() != info.getTotalSockets()) || (info.getCoresPerSocket() > info.getTotalCores())) println("Physical CPUs.." + info.getTotalSockets()); println("Cores per CPU.." + info.getCoresPerSocket());
CpuInfo[] cpuInfoList = sigar.getCpuInfoList(); if (cpuInfoList.length != 0) { generalInfo.setCpuModel(cpuInfoList[0].getModel()); generalInfo.setCpuMHz(cpuInfoList[0].getMhz()); generalInfo.setCpuTotalCores(cpuInfoList[0].getTotalCores()); generalInfo.setCpuTotalSockets(cpuInfoList[0].getTotalSockets());
public List<String> getCPUInfo() { ArrayList<String> result = new ArrayList<String>(); try { CpuInfo[] cpuInfoList = sigar.getCpuInfoList(); for (CpuInfo cpuInfo : cpuInfoList) { String cpu = String.format(cpuTemplate, cpuInfo.getModel(), cpuInfo.getMhz(), cpuInfo.getTotalCores()); result.add(cpu); } } catch (Exception e) { logger.warn("exception during getCPUInfo", e); } logger.trace("getCPUInfo: {}", result); return result; }
@Override public Integer getValue() { return cpuInfo.getTotalCores(); } });
@Override public Long getValue() { return cpuInfo.getCacheSize(); } });
@Override public Integer getValue() { return cpuInfo.getMhz(); } });
public int physicalCpuCount() { if (info == null) { return -1; } return info.getTotalSockets(); }
@Check public CPUEvent getCPU() { final CPUEvent cpuEvent = new CPUEvent(); final SigarProxy instance = SystemInstance.get().getComponent(SigarProxy.class); if (instance == null) { return null; } final CPU cpu = new CPU(); try { cpuEvent.setCategory("cpu"); cpuEvent.setSubCategory(instance.getCpuInfoList()[0].getModel()); cpu .setCombinedPercent(instance.getCpuPerc().getCombined() * 100) .setIdleTimePercent(instance.getCpuPerc().getIdle() * 100) .setIrqTimePercent(instance.getCpuPerc().getIrq() * 100) .setNiceTimePercent(instance.getCpuPerc().getNice() * 100) .setSoftIrqPercent(instance.getCpuPerc().getSoftIrq() * 100) .setStolenTimePercent(instance.getCpuPerc().getStolen() * 100) .setSysTimePercent(instance.getCpuPerc().getSys() * 100) .setUserTimePercent(instance.getCpuPerc().getUser() * 100) .setWaitTimePercent(instance.getCpuPerc().getWait() * 100); cpuEvent .setModel(instance.getCpuInfoList()[0].getModel()) .setCpu(cpu); } catch (final SigarException e) { LOGGER.log(LOG_LEVEL, "Error getting cpu metrics from Sigar", e); } return !Double.isNaN(cpu.getUserTimePercent()) ? cpuEvent : null; }
for (int i = 0; i < cpuinfo.length; i++) { Map cpuMap = new HashMap(); cpuMap.putAll(cpuinfo[i].toMap()); cpuMap.put("combined", cpuPerc[i].getCombined()); cpuMap.put("user", cpuPerc[i].getUser());
@Override public Integer getValue() { return cpuInfo.getTotalCores(); } });
if (cpuInfo.getCacheSize() != Sigar.FIELD_NOTIMPL) { metrics.put(name("cpu_info_cache").build(), new Gauge<Long>() { @Override
@Override public Integer getValue() { return cpuInfo.getMhz(); } });
public Object doMonitor(Map<String, Object> params) throws Exception { CpuInfo[] cpuInfos = SigarFactory.getSigar().getCpuInfoList(); List<Map> result = Lists.newArrayList(); if (cpuInfos != null) { for (CpuInfo cpuInfo : cpuInfos) { result.add(cpuInfo.toMap()); } } return result; }
final CpuInfo[] cpuInfos = sigar.getCpuInfoList(); final String vendor = cpuInfos[0].getVendor(); final String model = cpuInfos[0].getModel(); final int mhz = cpuInfos[0].getMhz(); final int totalCores = cpuInfos[0].getTotalCores(); final int totalSockets = cpuInfos[0].getTotalSockets(); final int coresPerSocket = cpuInfos[0].getCoresPerSocket(); long cacheSize = -1L; if (cpuInfos[0].getCacheSize() != Sigar.FIELD_NOTIMPL) { cacheSize = cpuInfos[0].getCacheSize();
public int totalCoreCount() { if (info == null) { return -1; } return info.getTotalCores(); }
@Override public Long getValue() { return cpuInfo.getCacheSize(); } });
for (int i = 0; i < cpuinfo.length; i++) { JSONObject cpuMap = new JSONObject(); cpuMap.putAll(cpuinfo[i].toMap()); cpuMap.put("combined", cpuPerc[i].getCombined() * 100); cpuMap.put("user", cpuPerc[i].getUser() * 100);
public CPU(int index, CpuInfo info, CpuPerc perc) { this.index = index; this.cacheSize = info.getCacheSize(); this.coresPerSocket = info.getCoresPerSocket(); this.totalCores = info.getTotalCores(); this.totalSockets = info.getTotalSockets(); this.mhz = info.getMhz(); this.model = info.getModel(); this.vendor = info.getVendor(); this.user = perc.getUser(); this.sys = perc.getSys(); this.nice = perc.getNice(); this.idle = perc.getIdle(); this.wait = perc.getWait(); this.irq = perc.getIrq(); this.softIrq = perc.getSoftIrq(); this.stolen = perc.getStolen(); this.combined = perc.getCombined(); }
private static void getNumberOfCPUs( SigarWrapper sigarWrapper ) throws SigarException { if( numberOfCPUs == 0 ) { numberOfCPUs = sigarWrapper.getSigarInstance().getCpuInfoList()[0].getTotalCores(); log.info( "Detected " + numberOfCPUs + " CPUs" ); } }
if (cpuInfo.getCacheSize() != Sigar.FIELD_NOTIMPL) { metrics.put(name("cpu_info_cache").build(), new Gauge<Long>() { @Override