Search in sources :

Example 1 with ProcMem

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);
}
Also used : Sigar(org.hyperic.sigar.Sigar) SigarException(org.hyperic.sigar.SigarException) ProcCpu(org.hyperic.sigar.ProcCpu) ProcMem(org.hyperic.sigar.ProcMem)

Aggregations

ProcCpu (org.hyperic.sigar.ProcCpu)1 ProcMem (org.hyperic.sigar.ProcMem)1 Sigar (org.hyperic.sigar.Sigar)1 SigarException (org.hyperic.sigar.SigarException)1