private int getCpuCore() { try { return sigar.getCpuList().length; } catch (SigarException e) { return 1; } } }
protected CPUTotalMetric(SigarProxy aSigar, MetricParamsSigar params) { super(aSigar, params); if (params.type.length() == 0) { type = COMBINED; } else { type = Arrays.asList(types).indexOf(params.type); if (type < 0) { throw new IllegalArgumentException("Invalid total cpu type: " + params.type); } } if (params.coreID >= 0) { int avail; try { avail = aSigar.getCpuList().length; } catch (SigarException ex) { throw new IllegalArgumentException("Cannot get CPU count at this system: " + ex.getMessage()); } if (params.coreID >= avail) { throw new IllegalArgumentException("Invalid core ID on this system: " + params.type); } coreID = params.coreID; } }
protected CPUTotalMetric(SigarProxy aSigar, MetricParamsSigar params) { super(aSigar, params); if (params.type.length() == 0) { type = COMBINED; } else { type = Arrays.asList(types).indexOf(params.type); if (type < 0) { throw new IllegalArgumentException("Invalid total cpu type: " + params.type); } } if (params.coreID >= 0) { int avail; try { avail = aSigar.getCpuList().length; } catch (SigarException ex) { throw new IllegalArgumentException("Cannot get CPU count at this system: " + ex.getMessage()); } if (params.coreID >= avail) { throw new IllegalArgumentException("Invalid core ID on this system: " + params.type); } coreID = params.coreID; } }
Cpu[] cpuList = sigar.getCpuList(); if (cpuList != null && this.cpuIndex < cpuList.length) { this.cpu = cpuList[this.cpuIndex];
Cpu[] cpuList = sigar.getCpuList(); if (cpuList != null && this.cpuIndex < cpuList.length) { this.cpu = cpuList[this.cpuIndex];
private Collection<Definition> collectMetrics() { final Collection<Definition> definitions = new HashSet<>(); // global addCpu(definitions, "sigar.cpu.", () -> sigar.getCpu()); addMem(definitions); // individual CPU try { final CpuInfo[] cpuInfoList = sigar.getCpuInfoList(); IntStream.range(0, cpuInfoList.length) .forEach(idx -> addCpu(definitions, "sigar.cpu." + idx + ".", () -> sigar.getCpuList()[idx])); } catch (final SigarException se) { // ignore } // network addNetwork(definitions); // filesystem addFileSystem(definitions); return definitions; }