use of org.hyperic.sigar.ProcMem in project graylog2-server by Graylog2.
the class SigarProcessProbe method processStats.
@Override
public synchronized ProcessStats processStats() {
final Sigar sigar = sigarService.sigar();
final long pid = sigar.getPid();
final long openFileDescriptors = JmxProcessProbe.getOpenFileDescriptorCount();
final long maxFileDescriptorCount = JmxProcessProbe.getMaxFileDescriptorCount();
ProcessStats.Cpu cpu;
try {
ProcCpu procCpu = sigar.getProcCpu(pid);
cpu = ProcessStats.Cpu.create((short) (procCpu.getPercent() * 100), procCpu.getSys(), procCpu.getUser(), procCpu.getTotal());
} catch (SigarException e) {
cpu = null;
}
ProcessStats.Memory memory;
try {
ProcMem mem = sigar.getProcMem(sigar.getPid());
memory = ProcessStats.Memory.create(mem.getSize(), mem.getResident(), mem.getShare());
} catch (SigarException e) {
memory = null;
}
return ProcessStats.create(pid, openFileDescriptors, maxFileDescriptorCount, cpu, memory);
}
Aggregations