SDR 0.73 to FreeBSD

Hi,

Im trying to put together a number of data recorders, to collect
raw data from kernel or from applications. Here you can see a basic
idea of SDR:
http://www.systemdatarecorder.org/recording/recdesign.html
http://www.systemdatarecorder.org/recording/recorders.html

Im currently trying to port sysrec,
http://www.systemdatarecorder.org/recording/sdr_bin/sysrec
to FreeBSD. I would like to understand how CPU Utilization
in FreeBSD counts, comparing to Solaris. Currently sysrec
records the following metrics:

Code:
# Utilisation,
#           CPU            # usr + sys time across all CPUs
#           Memory         # free RAM. freemem from availrmem
#           Disk           # %busy. r+w times across all Disks
#           Network        # throughput. r+w bytes across all NICs
#
# Saturation,
#           CPU            # threads on the run queue
#           Memory         # scan rate of the page scanner
#           Disk           # operations on the wait queue
#           Network        # errors due to buffer saturation
#

Would be fair to count CPU Util in FreeBSD similar with Solaris,
User + System time ? Is there any Perl module or KSTAT functionality which exports these functionalities to userland for simple consumption ?

Any ready made Perl modules which outputs such metrics for
FreeBSD ?

Many thanks,
Stefan
 
sparvu said:
Would be fair to count CPU Util in FreeBSD similar with Solaris, User + System time ?
Sounds reasonable.

Is there any Perl module or KSTAT functionality which exports these functionalities to userland for simple consumption ?
KStat is a distinctly Solaris feature. The BSD equivalent would probably be sysctl.

Any ready made Perl modules which outputs such metrics for FreeBSD ?
Not sure about perl modules but you can take a peek in the source of systat(1), vmstat(8) and iostat(8).
 
Thanks for message. I need to dig into FreeBSD and check how should
I get CPU Util, Mem Util, Disk IO (r+w across all disks) and Net IO.

In Linux world the CPU Util was a bit complicated, using different
formulas based on kernel version. Thats why Solaris is simpler
in that respect. I hope I can find in FreeBSD same or almost same
path as in Solaris. Example in Linux, how one would take into account CPU Util, based on talks with the author of Sys::Statistics::Linux CPAN module:

> As example the total cpu usage on linux 2.4 is calculated
> with system + user + nice. Since kernel 2.6 with
> user + system + nice + irq + softirq + iowait + steal.
>
> For more informations you can take a look into the manpage
> of the /proc filesystem (man 5 proc) and into /proc/stat.
>

/proc/stat
kernel/system statistics. Varies with architecture. Common
entries include:

cpu 3357 0 4313 1362393
The amount of time, measured in units of USER_HZ
(1/100ths of a second on most architectures, use
sysconf(_SC_CLK_TCK) to obtain the right value), that the
system spent in user mode, user mode with low priority
(nice), system mode, and the idle task, respectively.
The last value should be USER_HZ times the second entry
in the uptime pseudo-file.

In Linux 2.6 this line includes three additional columns:
iowait - time waiting for I/O to complete (since 2.5.41);
irq - time servicing interrupts (since 2.6.0-test4);
softirq - time servicing softirqs (since 2.6.0-test4).

Since Linux 2.6.11, there is an eighth column, steal -
stolen time, which is the time spent in other operating
systems when running in a virtualized environment

Since Linux 2.6.24, there is a ninth column, guest, which
is the time spent running a virtual CPU for guest operat‐
ing systems under the control of the Linux kernel.
 
Look at the source for those 3 utilities I mentioned. It'll be in C but it would give you an idea where the data comes from.

FreeBSD also has /proc but it's slightly different compared to Linux'. The utilities in the base don't use it though, so it's probably best to avoid it.
 
cheers, I will do that. I will dedicate time for weekend of
reading.

Later on details.
 
Back
Top