@Override CpuPerc loadSnapshot(Sigar sigar) throws SigarException { return sigar.getCpuPerc(); }
cpuList.add(cpuMap); sigar.getCpuPerc(); map.put("cpu", cpuList);
/** * Returns the CPU usage information. * @return the CPU usage information. * @throws SigarException if fails. */ public double getCPUUsage() throws SigarException { return sigar.getCpuPerc().getCombined(); }
output(this.sigar.getCpuPerc());
final CpuPerc cpuPerc = sigar.getCpuPerc(); final short sys = (short) (cpuPerc.getSys() * 100); final short user = (short) (cpuPerc.getUser() * 100);
cpuList.add(cpuMap); sigar.getCpuPerc(); json.put("cpu", cpuList);
CpuPerc cpu = sigar.getCpuPerc(); double system = cpu.getSys(); double user = cpu.getUser();
@Override CpuPerc loadSnapshot(Sigar sigar) throws SigarException { return sigar.getCpuPerc(); }
public CpuPerc getCpuPerc() throws SigarException {return _sigar.getCpuPerc();}
/** * Execute the collector to get the system info model. * * @return SystemInfo in current time */ public synchronized SystemInfo execute() { SystemInfo systemInfo = new SystemInfo(); systemInfo.setCollectTime(System.currentTimeMillis()); try { BandWidth networkUsage = getNetworkUsage(); BandWidth bandWidth = networkUsage.adjust(prev.getBandWidth()); systemInfo.setBandWidth(bandWidth); systemInfo.setCPUUsedPercentage((float) sigar.getCpuPerc().getCombined() * 100); Cpu cpu = sigar.getCpu(); systemInfo.setTotalCpuValue(cpu.getTotal()); systemInfo.setIdleCpuValue(cpu.getIdle()); Mem mem = sigar.getMem(); systemInfo.setTotalMemory(mem.getTotal() / 1024L); systemInfo.setFreeMemory(mem.getActualFree() / 1024L); systemInfo.setSystem(OperatingSystem.IS_WIN32 ? SystemInfo.System.WINDOW : SystemInfo.System.LINUX); systemInfo.setCustomValues(getCustomMonitorData()); } catch (Throwable e) { LOGGER.error("Error while getting system perf data:{}", e.getMessage()); LOGGER.debug("Error trace is ", e); } prev = systemInfo; return systemInfo; }
@Override protected CpuPerc loadValue() { try { return sigar.getCpuPerc(); } catch (SigarException e) { throw new RuntimeException("Failed to get cpu info from sigar", e); } } }
@Override public Double getValue() { try { return sigar.getCpuPerc().getCombined(); } catch (SigarException e) { logger.error("CPU monitor exception: ", e); } return 0.; } });
Sigar sigar = new Sigar(); CpuPerc perc = sigar.getCpuPerc(); System.out.println(perc.getCpuPerc());
@Override public CpuData getCpuData() { CpuData data = new CpuData(); try { CpuPerc cpuPerc = sigar.getCpuPerc(); double value = cpuPerc.getIdle(); data.setCpuStateIdle(Double.isNaN(value) ? 0 : value); value = cpuPerc.getSys(); data.setCpuStateSys(Double.isNaN(value) ? 0 : value); value = cpuPerc.getUser(); data.setCpuStateUser(Double.isNaN(value) ? 0 : value); value = cpuPerc.getWait(); data.setCpuStateWait(Double.isNaN(value) ? 0 : value); value = cpuPerc.getCombined(); data.setCpuStateCombined(Double.isNaN(value) ? 0 : value); logger.debug("getCpuData: {}", data); } catch (SigarException e) { logger.warn("Exception during getCpuData", e); } return data; }
/** * called on each poll * * @throws SigarException * @throws MonitorConfigurationException */ void refresh() throws SigarException, MonitorConfigurationException { try { this.swap = this.sigar.getSwap(); this.memory = this.sigar.getMem(); this.cpu = this.sigar.getCpu(); this.cpuPerc = this.sigar.getCpuPerc(); if( !OperatingSystemType.getCurrentOsType().equals( OperatingSystemType.AIX ) ) { this.netstat = this.sigar.getNetStat(); this.tcp = this.sigar.getTcp(); } this.loadAvrg = new SigarLoadAverage( this.sigar ); } catch( Exception e ) { final String errorMsg = "Error retrieving data from the Sigar monitoring system"; log.error( errorMsg, e ); throw new MonitorConfigurationException( errorMsg, e ); } }
CpuPerc cpuPerc = sigar.getCpuPerc();
final CpuPerc cpuPerc = sigar.getCpuPerc(); final short sys = (short) (cpuPerc.getSys() * 100); final short user = (short) (cpuPerc.getUser() * 100);
final CpuPerc cpuPerc = sigar.getCpuPerc(); final short sys = (short) (cpuPerc.getSys() * 100); final short user = (short) (cpuPerc.getUser() * 100);