Package org.hyperic.sigar

Examples of org.hyperic.sigar.ProcCpu


        ProcessStats stats = new ProcessStats();
        stats.timestamp = System.currentTimeMillis();
        stats.openFileDescriptors = JmxProcessProbe.getOpenFileDescriptorCount();

        try {
            ProcCpu cpu = sigar.getProcCpu(sigar.getPid());
            stats.cpu = new ProcessStats.Cpu();
            stats.cpu.percent = (short) (cpu.getPercent() * 100);
            stats.cpu.sys = cpu.getSys();
            stats.cpu.user = cpu.getUser();
        } catch (SigarException e) {
            // ignore
        }

        try {
View Full Code Here


                    info = Ps.getInfo(sigar, pid);
                } catch (SigarException e) {
                    continue; //process may have gone away
                }
                try {
                    ProcCpu cpu = sigar.getProcCpu(pid);
                    cpuPerc = CpuPerc.format(cpu.getPercent());
                } catch (SigarException e) {
                }

                info.add(info.size()-1, cpuPerc);
View Full Code Here

        }

        pObj.setProcessState(String.valueOf(state.getState()));

        try {
            ProcCpu cpu = sigar.getProcCpu(pid);
            int cpuCores = sigar.getCpuInfoList()[0].getTotalCores();
            int cpuSockets = sigar.getCpuInfoList()[0].getTotalSockets();

            if(cpuSockets == 0 || cpuCores == 0){
                cpuCores = cpuSockets = 1;
            }
           
            pObj.setProcessCPUPercentage((cpu.getPercent() /
                    (cpuCores * cpuSockets)));
           
        } catch (SigarException e) {           
        }

View Full Code Here

        try {
            sigar.getProcTime(getInvalidPid());
        } catch (SigarException e) {
        }

        ProcCpu procTime = sigar.getProcCpu(sigar.getPid());

        assertGtEqZeroTrace("StartTime", procTime.getStartTime());
        traceln("StartDate=" + new Date(procTime.getStartTime()));
        //XXX
        //assertTrue(procTime.getStartTime() < System.currentTimeMillis());

        assertGtEqZeroTrace("User", procTime.getUser());

        assertGtEqZeroTrace("Sys", procTime.getSys());

        assertGtEqZeroTrace("Total", procTime.getTotal());

        double value = procTime.getPercent() * 100.0;
        traceln("Percent=" + value);
        assertTrue(value >= 0.0);
        assertTrue(value <= 100.0);
    }
View Full Code Here

        try {
            sigar.getProcTime(getInvalidPid());
        } catch (SigarException e) {
        }

        ProcCpu procTime = sigar.getProcCpu(sigar.getPid());

        assertGtEqZeroTrace("StartTime", procTime.getStartTime());
        traceln("StartDate=" + new Date(procTime.getStartTime()));
        //XXX
        //assertTrue(procTime.getStartTime() < System.currentTimeMillis());

        assertGtEqZeroTrace("User", procTime.getUser());

        assertGtEqZeroTrace("Sys", procTime.getSys());

        assertGtEqZeroTrace("Total", procTime.getTotal());

        double value = procTime.getPercent() * 100.0;
        traceln("Percent=" + value);
        assertTrue(value >= 0.0);
        int ncpu = sigar.getCpuList().length;
        assertTrue(value <= (100.0 * ncpu)); //SIGAR-145 Irix mode
    }
View Full Code Here

                    info = Ps.getInfo(sigar, pid);
                } catch (SigarException e) {
                    continue; //process may have gone away
                }
                try {
                    ProcCpu cpu = sigar.getProcCpu(pid);
                    cpuPerc = CpuPerc.format(cpu.getPercent());
                } catch (SigarException e) {
                }

                info.add(info.size()-1, cpuPerc);
View Full Code Here

                String cpuPerc = "?";

                List info = Ps.getInfo(sigar, pid);
                try {
                    ProcCpu cpu = sigar.getProcCpu(pid);
                    cpuPerc = CpuPerc.format(cpu.getPercent());
                } catch (SigarException e) {
                }

                info.add(info.size()-1, cpuPerc);
View Full Code Here

        ProcessStats stats = new ProcessStats();
        stats.timestamp = System.currentTimeMillis();
        stats.openFileDescriptors = JmxProcessProbe.getOpenFileDescriptorCount();

        try {
            ProcCpu cpu = sigar.getProcCpu(sigar.getPid());
            stats.cpu = new ProcessStats.Cpu();
            stats.cpu.percent = (short) (cpu.getPercent() * 100);
            stats.cpu.sys = cpu.getSys();
            stats.cpu.user = cpu.getUser();
            stats.cpu.total = cpu.getTotal();
        } catch (SigarException e) {
            // ignore
        }

        try {
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.ProcCpu

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.