[users at i-scream] freebsd user sg_get_cpu_percent very different than top output.
Tim Bishop
tim at bishnet.net
Tue Mar 14 15:01:18 GMT 2017
On Tue, Mar 14, 2017 at 03:55:05PM +0100, Jesper Schmitz Mouridsen wrote:
> tirsdag den 14. marts 2017 11.39.04 CET skrev Tim Bishop:
> > 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% ...
> >
> > Is the first run of statgrab outputting something different? Try:
> >
> > statgrab -p -s cpu.
> >
> > This will keep outputting every second.
>
> And that makes output values corresponding to top.
> Thanks.
>
> Also I found cpu-usage.c in examples, which also gives output like top.
> From cpu-usage.c:
> /* Throw away the first reading as thats averaged over the machines uptime
> */
> sg_snapshot();
> cpu_percent = sg_get_cpu_percents(NULL);
>
> So just calling sg_get_cpu_percents once of course is different than top
> output.
Have you noticed how top on FreeBSD doesn't display CPU figures
immediately? It's only on the refresh that the get filled in. Maybe it's
doing the same thing.
Tim.
--
Tim Bishop
http://www.bishnet.net/tim/
PGP Key: 0x6C226B37FDF38D55
More information about the users
mailing list