[users at i-scream] freebsd user sg_get_cpu_percent very different than top output.
Jesper Schmitz Mouridsen
jesper at schmitz.computer
Tue Mar 14 14:55:05 GMT 2017
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.
Thanks again.
/Jesper
More information about the users
mailing list