[users at i-scream] freebsd user sg_get_cpu_percent very different than top output.

Tim Bishop tim at bishnet.net
Tue Mar 14 10:39:04 GMT 2017


On Tue, Mar 14, 2017 at 10:58:09AM +0100, Jesper Schmitz Mouridsen wrote:
> Hi.
> This is on FreeBSD 11.0-RELEASE-p8
> I'm trying to get libstatgrab to report the cpu-usage correctly 
> (e.g with values like top).
> 
> When I max out the cpu use of libstatsgrab and statgrab still reports < 10%
> for cpu userspace percent.
> TOP:
> CPU: 82.7% user,  0.0% nice, 13.2% system,  0.0% interrupt,  4.0% idle
> Statgrab:
> cpu.ctxsw: 0
> cpu.idle: 88.292770
> cpu.intrs: 0
> cpu.iowait: 0.000000
> cpu.kernel: 6.643582
> cpu.nice: 0.000000
> cpu.nvctxsw: 0
> cpu.softintrs: 0
> cpu.swap: 0.000000
> cpu.syscalls: 0
> cpu.time_taken: 1489484539
> cpu.user: 5.039125
> 
> On Linux (in a vm, I also find significant difference between top and 
> statgrab)
> What am I missing?

Is the first run of statgrab outputting something different? Try:

statgrab -p -s cpu.

This will keep outputting every second.

Tim.

-- 
Tim Bishop
http://www.bishnet.net/tim/
PGP Key: 0x6C226B37FDF38D55




More information about the users mailing list