[users at i-scream] freebsd user sg_get_cpu_percent very different than top output.
Danny Weldon
danny.weldon at gmail.com
Wed Mar 15 10:44:29 GMT 2017
On 15 March 2017 at 01:01, Tim Bishop <tim at bishnet.net> wrote:
> 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
>
>
> _______________________________________________
> users mailing list
> users at i-scream.org
> https://lists.i-scream.org/mailman/listinfo/users
This is fairly standard for unix monitoring utilities, for example from
the Linux iostat man page (from the sysstat package):
The first report generated by the iostat command provides statistics
concerning the time since the system was booted, unless the -y option
is used (in this case, this first report is omitted). Each subsequent
report covers the time since the previous report. All statistics are
reported each time the iostat command is run. The report consists of a
More information about the users
mailing list