Quantcast
Channel: VMware Communities : Popular Discussions - Hyperic User Forums
Viewing all articles
Browse latest Browse all 52618

Invalid cpu usage per process

$
0
0
After several hours of testing, and trying to make this work I give up.

Test results:
Windows XP x86  - process cpu usages are correct ( after comparing them with task manager)

HP-UX 11.23 IA64 - process cpu usages are correct only for processes that are using more than 3-4 % of cpu. I have one process that is running between 0.8 and 2.95% but sigar is returning me 3.2 then some zeros and then again 3.2, after leaving to monitor for longer time, only decimals are changing.  All values are comparing to TOP command.

Solaris running on sparc ( not 64) I'm monitoring java process that is using 2-10% of cpu and sigar is returning 58-80%, what is completely wrong. Once again all numbers are compared to top command.

And now to gathering method:

public class Top extends SigarCommandBase {

    private static Logger m_logger = null;

    public void getData( long pid) {

        try {
            ProcCpu procCPU = this.proxy.getProcCpu( pid);           
            ProcState procState = sigar.getProcState(pid);          
            System.out.println( pid + "\t\t" + procState.getName() +"\t\t" +
                            procCPU.getPercent()*100);           
           
        } catch ( SigarException ee){
            m_logger.error("SigarException", e);
        } catch( Exception e) {
            m_logger.error("Error getting data", e);
        }
    }

    public void runProgram( int pid) throws Exception {
        m_logger.info("Start checking cpu usage.");

        while(true) {

            getData( pid);           
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
                m_logger.error("interupted sleep", e);
            }
        }
    }

    public static void main(String[] args) throws Exception {
        org.apache.log4j.PropertyConfigurator.configureAndWatch( "log4j.properties");
        m_logger = Logger.getLogger(Top.class);
       
        if( args.length<1)
            m_logger.error("No argument for pid.");
        else
            new Top().runProgram( Integer.valueOf( args[0]));
    }

    @Override
    public void output(String[] strings) throws SigarException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}


I was using Top.java from sample of sigar. But can't get values near top command.

I'm wondering if reading process cpu usage actualy works ?

I will be very grateful for any help with my issue.

Viewing all articles
Browse latest Browse all 52618

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>