Pergunta

I'm trying to develop a small testing application that runs a few commands on and every X seconds measures cpu usage,memory usage and network utilization as seen in Windows Task Manager. the Application will be written in java and is supposed to run on both windows and linux. I have found that many people uses the Sigar API in order to extract system information easily. I found out how to use it to extract memory usage using

 Mem mem = sigar.getMem();
 mem.getUsed();

I'm still not sure what the difference is between memory used and actual memory used, can someone elaborate me on this?

Also I'm still not sure how to extract Cpu usage and network utilization. for Cpu I have tried:

cpu = sigar.getCpuPerc();
cpu.getCombined();

but the numbers seems very different from what I'm seeing in the Task Manager. which API should I use to get the desired results? for network utilization I have no clue.

Foi útil?

Solução

Memory used refer to the allocated memory size, actual memory used is the one which is actually used out of the allocated, it reduces some kernel and other areas memory from it.

For CPU, I also figured out values to be different and seen some blog where it suggest to multiply by 100. So I did, now the values are quite similar... http://code.google.com/p/starfire/source/browse/trunk/starfire/src/main/java/es/upm/dit/gsi/starfire/capability/systemMonitor/CpuMonitor.java?spec=svn279&r=279

Network I am still searching.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top