System.out.println(toString(sigar.getProcStat())); System.out.println(sigar.getCpuPerc()); System.out.println(sigar.getMem()); System.out.println(sigar.getSwap()); ProcCpu cpu = sigar.getProcCpu(pid); cpuPerc = CpuPerc.format(cpu.getPercent()); } catch (SigarException e) {
public Collection getCompletions() { String[] ifNames; try { ifNames = this.proxy.getNetInterfaceList(); } catch (SigarException e) { return super.getCompletions(); } return Arrays.asList(ifNames); }
private void netUsage(int checkIntervalSec) { try { if (netIf == null) { netIf = sigar.getNetInterfaceList(); net = sigar.getNetInterfaceStat(netIfName); } catch (SigarException e) {
FileSystemMap mounts = this.proxy.getFileSystemMap(); for (int i=0; i<args.length; i++) { String arg = args[i]; FileSystem[] fslist = this.proxy.getFileSystemList(); for (int i=0; i<fslist.length; i++) { sys.add(fslist[i]);
public static SystemSnapshot snapshot(final SigarProxy sigar) { final SystemSnapshot systemSnapshot = new SystemSnapshot(); systemSnapshot.setPid(sigar.getPid()); try { systemSnapshot.setUptime(sigar.getUptime().getUptime()); } catch (final SigarException e) { systemSnapshot.setCpu(fromCopy(new CpuSnapshot(), sigar.getCpu())); } catch (final SigarException e) { systemSnapshot.setMemory(fromCopy(new MemorySnapshot(), sigar.getMem())); } catch (final SigarException e) { systemSnapshot.setProcesses(fromCopy(new ProcessesSnapshot(), sigar.getProcStat())); } catch (final SigarException e) { for (final FileSystem fs : sigar.getFileSystemList()) { if (fs.getType() == FileSystem.TYPE_LOCAL_DISK) { final String fsName = fs.getDirName(); final FileSystemUsage stats = sigar.getFileSystemUsage(fsName); final DiskSnapshot diskSnapshot = new DiskSnapshot(); diskSnapshot.setTotal(stats.getTotal()); diskSnapshot.setAvailable(stats.getAvail()); diskSnapshot.setUsed(stats.getUsed()); systemSnapshot.getDisks().put(fsName, fromCopy(diskSnapshot, sigar.getDiskUsage(fsName))); for (final String netInterface : sigar.getNetInterfaceList()) { systemSnapshot.getNetworks().put(netInterface, fromCopy(new NetworkSnapshot(), sigar.getNetInterfaceStat(netInterface)));
procState = sigar.getProcState(pid); } catch (Exception e) { handleSigarCallException(e, "getProcState"); procExe = sigar.getProcExe(pid); } catch (Exception e) { handleSigarCallException(e, "getProcExe"); String[] procArgs = null; try { procArgs = sigar.getProcArgs(pid); } catch (Exception e) { handleSigarCallException(e, "getProcArgs"); this.procEnv = sigar.getProcEnv(pid); if (this.procEnv == null) { LOG.debug("SIGAR returned a null environment for [" + getBaseName() + "] process with pid [" this.procTime = sigar.getProcTime(pid); } catch (Exception e) { handleSigarCallException(e, "getProcTime"); this.procMem = sigar.getProcMem(pid); } catch (Exception e) { handleSigarCallException(e, "getProcMem"); this.procCpu = sigar.getProcCpu(pid); } catch (Exception e) { handleSigarCallException(e, "getProcCpu");
_args = sigar.getProcArgs(pid); } catch (SigarException e) { _args = new String[] {}; _env = sigar.getProcEnv(pid); } catch (SigarException e) { _env = new HashMap(); _procState = sigar.getProcState(pid); final String unknown = "???"; _procCredName = sigar.getProcCredName(pid); _owner = _procCredName.getUser(); } catch (SigarException e) { _procDiskIO = sigar.getProcDiskIO(pid); _totalDiskBytes = _procDiskIO.getBytesTotal(); _diskBytesRead = _procDiskIO.getBytesRead(); _procCpu = sigar.getProcCpu(pid); _startTime = _procCpu.getStartTime(); } catch (SigarException e) { _procMem = sigar.getProcMem(pid); _size = _procMem.getSize(); _resident = _procMem.getResident(); _share = _procMem.getShare(); _memPerc = (double) _resident / sigar.getMem().getTotal(); } catch (SigarException e) {
/** * {@inheritDoc} */ @Override public void sample(final IMonitoringController monitoringCtr) throws SigarException { if (!monitoringCtr.isMonitoringEnabled()) { return; } if (!monitoringCtr.isProbeActivated(SignatureFactory.createMemSwapSignature())) { return; } final Mem mem = this.sigar.getMem(); final Swap swap = this.sigar.getSwap(); final MemSwapUsageRecord r = new MemSwapUsageRecord( monitoringCtr.getTimeSource().getTime(), monitoringCtr.getHostname(), mem.getTotal(), mem.getActualUsed(), mem.getActualFree(), swap.getTotal(), swap.getUsed(), swap.getFree()); monitoringCtr.newMonitoringRecord(r); } }
public List<NetworkAdapterInfo> getAllNetworkAdapters() throws SystemInfoException { List<NetworkAdapterInfo> adapters = new ArrayList<NetworkAdapterInfo>(); try { String[] interfaceNames = sigar.getNetInterfaceList(); if (interfaceNames != null) { for (String interfaceName : interfaceNames) { if (interfaceName.indexOf(':') != -1) { continue; //filter out virtual IPs } adapters.add(new NetworkAdapterInfo(sigar.getNetInterfaceConfig(interfaceName))); } } } catch (Exception e) { throw new SystemInfoException(e); } return adapters; }
public NetworkAdapterStats getNetworkAdapterStats(String interfaceName) { try { NetInterfaceStat interfaceStat = sigar.getNetInterfaceStat(interfaceName); return new NetworkAdapterStats(interfaceStat); } catch (SigarException e) { throw new SystemInfoException(e); } }
public static List getInfo(SigarProxy sigar, long pid) throws SigarException { ProcState state = sigar.getProcState(pid); ProcTime time = null; String unknown = "???"; ProcCredName cred = sigar.getProcCredName(pid); info.add(cred.getUser()); } catch (SigarException e) { time = sigar.getProcTime(pid); info.add(getStartTime(time.getStartTime())); } catch (SigarException e) { ProcMem mem = sigar.getProcMem(pid); info.add(Sigar.formatSize(mem.getSize())); info.add(Sigar.formatSize(mem.getRss()));
private void diskIO(int checkIntervalSec) { try { if (fs == null) { fs = sigar.getFileSystemList(); FileSystemUsage usage = null; try { usage = sigar.getFileSystemUsage(fs[i].getDirName()); } catch (SigarException e) { if(!fsExceptionOccured.contains(fs[i].getDirName())) {
public Mem getMemoryInfo() { try { return sigar.getMem(); } catch (Exception e) { throw new UnsupportedOperationException("Cannot get memory info from native layer", e); } }
for (final String netInterface : instance.getNetInterfaceList()) { if ("0.0.0.0".equals(instance.getNetInterfaceConfig(netInterface).getAddress())) continue; final NetInterfaceStat stats = instance.getNetInterfaceStat(netInterface); if (stats != null) { final NetworkEvent netEvent = new NetworkEvent();
CpuPerc cpuPerc = sigar.getCpuPerc(); float cpu = (float) ((1.0D - cpuPerc.getIdle()) * 100); cpuMeter.add(cpu); Mem m = sigar.getMem(); alertMem(m); float memrate = (float) m.getUsedPercent(); Swap sw = sigar.getSwap(); long pagein = sw.getPageIn(); long pageout = sw.getPageOut();
public void refresh(SigarProxy sigar) throws Exception { // There are some instances where SIGAR can't get one or more of these (maybe permission issues?). // Do not bomb if we can't get one or more of these - we'll just handle nulls appropriately. try { childProcTime = sigar.getProcTime(this.childPid); } catch (Exception e) { } try { childProcMem = sigar.getProcMem(this.childPid); } catch (Exception e) { } try { childProcCpu = sigar.getProcCpu(this.childPid); } catch (Exception e) { } try { childProcFd = sigar.getProcFd(this.childPid); } catch (Exception e) { } } }
public ServerContext(final ServerDetails serverDetails) { final SigarProxy instance = SystemInstance.get().getComponent(SigarProxy.class); if (instance != null) { try { setCpuUsedPercent((int) Math.round(instance.getCpuPerc().getCombined() * 100.0D)); } catch (SigarException ignore) { } try { setMemoryUsedPercent((int) Math.round(instance.getMem().getUsedPercent())); } catch (SigarException ignore) { } try { String serverBaseDirectory = SystemInstance.get().getComponent(Environment.class).getServerBaseDirectory(); setFsUsedPercent((int) Math.round(instance.getFileSystemUsage(serverBaseDirectory).getUsePercent() * 100D)); } catch (SigarException ignore) { } } setDataCenter(serverDetails.getDataCenter()); setEnvironment(serverDetails.getEnvironment()); setSource(SystemInstance.get().getProperty("com.tomitribe.tribestream.serverType")); setServerHost(serverDetails.getFullHostname()); setServerIp(serverDetails.getIpAddress()); setServerName(serverDetails.getShortHostname()); }
public void output(String[] args) throws SigarException { if (args.length == 1) { String arg = args[0]; if ((arg.indexOf('/') != -1) || (arg.indexOf('\\') != -1)) { outputFileSystem(arg); } else { outputDisk(arg); } } else { FileSystem[] fslist = this.proxy.getFileSystemList(); printHeader(); for (int i=0; i<fslist.length; i++) { if (fslist[i].getType() == FileSystem.TYPE_LOCAL_DISK) { output(fslist[i]); } } } }
CpuInfo[] cpuInfoList = sigar.getCpuInfoList(); if (cpuInfoList != null && cpuInfoList.length >= 1) { Cpu[] cpuList = sigar.getCpuList(); if (cpuList != null && this.cpuIndex < cpuList.length) { this.cpu = cpuList[this.cpuIndex]; CpuPerc[] cpuPercentageList = sigar.getCpuPercList(); if (cpuPercentageList != null && this.cpuIndex < cpuPercentageList.length) { this.cpuPercentage = cpuPercentageList[this.cpuIndex];
public Swap getSwapInfo() { try { // Removed this check since http://jira.hyperic.com/browse/SIGAR-112 is fixed. /* int enabledCpuCount = sigar.getCpuPercList().length; int totalCpuCount = sigar.getCpuInfoList().length; if (enabledCpuCount < totalCpuCount) { log.info("Aborting swap info collection because one or more CPUs is disabled - " + enabledCpuCount + " out of " + totalCpuCount + " CPUs are enabled."); return null; } */ return sigar.getSwap(); } catch (Exception e) { throw new UnsupportedOperationException("Cannot get swap info from native layer", e); } }