1998-09-15 06:23:21 +00:00
|
|
|
.\"
|
2001-08-04 18:25:48 +00:00
|
|
|
.\" Copyright (c) 1998, 1999, 2001 Kenneth D. Merry.
|
1998-09-15 06:23:21 +00:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1998-09-15 06:23:21 +00:00
|
|
|
.\"
|
2005-06-30 06:35:51 +00:00
|
|
|
.Dd March 18, 2003
|
1998-09-15 06:23:21 +00:00
|
|
|
.Dt DEVSTAT 3
|
2001-07-10 13:41:46 +00:00
|
|
|
.Os
|
1998-09-15 06:23:21 +00:00
|
|
|
.Sh NAME
|
1999-09-21 19:22:30 +00:00
|
|
|
.Nm devstat ,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Nm devstat_getnumdevs ,
|
|
|
|
.Nm devstat_getgeneration ,
|
|
|
|
.Nm devstat_getversion ,
|
|
|
|
.Nm devstat_checkversion ,
|
|
|
|
.Nm devstat_getdevs ,
|
|
|
|
.Nm devstat_selectdevs ,
|
|
|
|
.Nm devstat_buildmatch ,
|
|
|
|
.Nm devstat_compute_statistics ,
|
2003-05-22 13:02:28 +00:00
|
|
|
.Nm devstat_compute_etime
|
1998-09-15 06:23:21 +00:00
|
|
|
.Nd device statistics utility library
|
2000-04-22 15:58:01 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libdevstat
|
1998-09-15 06:23:21 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In devstat.h
|
1998-09-15 06:23:21 +00:00
|
|
|
.Ft int
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fn devstat_getnumdevs "kvm_t *kd"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Ft long
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fn devstat_getgeneration "kvm_t *kd"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Ft int
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fn devstat_getversion "kvm_t *kd"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Ft int
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fn devstat_checkversion "kvm_t *kd"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Ft int
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fn devstat_getdevs "kvm_t *kd" "struct statinfo *stats"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Ft int
|
|
|
|
.Fo devstat_selectdevs
|
|
|
|
.Fa "struct device_selection **dev_select"
|
|
|
|
.Fa "int *num_selected"
|
|
|
|
.Fa "int *num_selections"
|
|
|
|
.Fa "long *select_generation"
|
|
|
|
.Fa "long current_generation"
|
|
|
|
.Fa "struct devstat *devices"
|
|
|
|
.Fa "int numdevs"
|
|
|
|
.Fa "struct devstat_match *matches"
|
|
|
|
.Fa "int num_matches"
|
|
|
|
.Fa "char **dev_selections"
|
|
|
|
.Fa "int num_dev_selections"
|
|
|
|
.Fa "devstat_select_mode select_mode"
|
|
|
|
.Fa "int maxshowdevs"
|
|
|
|
.Fa "int perf_select"
|
|
|
|
.Fc
|
|
|
|
.Ft int
|
|
|
|
.Fo devstat_buildmatch
|
|
|
|
.Fa "char *match_str"
|
|
|
|
.Fa "struct devstat_match **matches"
|
|
|
|
.Fa "int *num_matches"
|
|
|
|
.Fc
|
|
|
|
.Ft int
|
|
|
|
.Fo devstat_compute_statistics
|
|
|
|
.Fa "struct devstat *current"
|
|
|
|
.Fa "struct devstat *previous"
|
2001-10-03 03:57:42 +00:00
|
|
|
.Fa "long double etime"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fa "..."
|
|
|
|
.Fc
|
2005-06-30 06:35:51 +00:00
|
|
|
.Ft "long double"
|
2005-07-17 13:33:04 +00:00
|
|
|
.Fo devstat_compute_etime
|
|
|
|
.Fa "struct bintime *cur_time"
|
|
|
|
.Fa "struct bintime *prev_time"
|
|
|
|
.Fc
|
1998-09-15 06:23:21 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
library is a library of helper functions for dealing with the kernel
|
|
|
|
.Xr devstat 9
|
|
|
|
interface, which is accessible to users via
|
2001-08-04 18:25:48 +00:00
|
|
|
.Xr sysctl 3
|
|
|
|
and
|
|
|
|
.Xr kvm 3 .
|
2001-08-24 02:24:58 +00:00
|
|
|
All functions that take a
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt "kvm_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
as first argument can be passed
|
|
|
|
.Dv NULL
|
|
|
|
instead of a kvm handle as this argument,
|
|
|
|
which causes the data to be read via
|
1998-09-15 06:23:21 +00:00
|
|
|
.Xr sysctl 3 .
|
2001-08-04 18:25:48 +00:00
|
|
|
Otherwise, it is read via
|
|
|
|
.Xr kvm 3
|
|
|
|
using the supplied handle.
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_checkversion
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
2001-08-04 18:25:48 +00:00
|
|
|
should be called with each kvm handle that is going to be used (or with
|
|
|
|
.Dv NULL
|
|
|
|
if
|
|
|
|
.Xr sysctl 3
|
|
|
|
is going to be used).
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getnumdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
returns the number of devices registered with the
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
1998-09-15 06:23:21 +00:00
|
|
|
subsystem in the kernel.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getgeneration
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
returns the current generation of the
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
1998-09-15 06:23:21 +00:00
|
|
|
list of devices in the kernel.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getversion
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
returns the current kernel
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
1998-09-15 06:23:21 +00:00
|
|
|
version.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_checkversion
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
|
|
|
checks the userland
|
|
|
|
.Nm
|
|
|
|
version against the kernel
|
|
|
|
.Nm
|
|
|
|
version.
|
2001-08-04 18:25:48 +00:00
|
|
|
If the two are identical, it returns zero.
|
|
|
|
Otherwise, it prints an appropriate error in
|
1998-09-15 06:23:21 +00:00
|
|
|
.Va devstat_errbuf
|
2005-06-30 06:35:51 +00:00
|
|
|
and returns \-1.
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
fetches the current list of devices and statistics into the supplied
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt statinfo
|
2001-08-04 18:25:48 +00:00
|
|
|
structure.
|
|
|
|
The
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt statinfo
|
2001-07-15 07:53:42 +00:00
|
|
|
structure can be found in
|
2003-09-08 19:57:22 +00:00
|
|
|
.In devstat.h :
|
1998-09-15 06:23:21 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct statinfo {
|
|
|
|
long cp_time[CPUSTATES];
|
2001-07-15 07:53:42 +00:00
|
|
|
long tk_nin;
|
1998-09-15 06:23:21 +00:00
|
|
|
long tk_nout;
|
|
|
|
struct devinfo *dinfo;
|
2003-03-18 13:45:08 +00:00
|
|
|
long double snap_time;
|
1998-09-15 06:23:21 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
expects the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt statinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
structure to be allocated, and it also expects the
|
|
|
|
.Va dinfo
|
1999-09-23 06:36:02 +00:00
|
|
|
subelement to be allocated and zeroed prior to the first invocation of
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs .
|
1999-09-23 06:36:02 +00:00
|
|
|
The
|
|
|
|
.Va dinfo
|
|
|
|
subelement is used to store state between calls, and should not be modified
|
|
|
|
after the first call to
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs .
|
1999-09-23 06:36:02 +00:00
|
|
|
The
|
1998-09-15 06:23:21 +00:00
|
|
|
.Va dinfo
|
|
|
|
subelement contains the following elements:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct devinfo {
|
|
|
|
struct devstat *devices;
|
|
|
|
u_int8_t *mem_ptr;
|
1998-09-20 00:11:23 +00:00
|
|
|
long generation;
|
1998-09-15 06:23:21 +00:00
|
|
|
int numdevs;
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Va kern.devstat.all
|
2005-06-30 06:35:51 +00:00
|
|
|
.Xr sysctl 8
|
1998-09-15 06:23:21 +00:00
|
|
|
variable contains an array of
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
1998-09-15 06:23:21 +00:00
|
|
|
structures, but at the head of the array is the current
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
2001-08-04 18:25:48 +00:00
|
|
|
generation.
|
|
|
|
The reason the generation is at the head of the buffer is so that userland
|
2005-06-30 06:35:51 +00:00
|
|
|
software accessing the
|
|
|
|
.Nm
|
|
|
|
statistics information can atomically get
|
2001-08-04 18:25:48 +00:00
|
|
|
both the statistics information and the corresponding generation number.
|
|
|
|
If client software were forced to get the generation number via a separate
|
2005-06-30 06:35:51 +00:00
|
|
|
.Xr sysctl 8
|
1998-09-15 06:23:21 +00:00
|
|
|
variable (which is available for convenience), the list of devices could
|
|
|
|
change between the time the client gets the generation and the time the
|
|
|
|
client gets the device list.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Va mem_ptr
|
|
|
|
subelement of the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt devinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
structure is a pointer to memory that is allocated, and resized if
|
|
|
|
necessary, by
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs .
|
1998-09-15 06:23:21 +00:00
|
|
|
The devices subelement of the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt devinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
structure is basically a pointer to the beginning of the array of devstat
|
|
|
|
structures from the
|
|
|
|
.Va kern.devstat.all
|
2005-06-30 06:35:51 +00:00
|
|
|
.Xr sysctl 8
|
2001-08-04 18:25:48 +00:00
|
|
|
variable (or the corresponding values read via
|
|
|
|
.Xr kvm 3 ) .
|
|
|
|
The generation subelement of the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt devinfo
|
2001-08-04 18:25:48 +00:00
|
|
|
structure contains the corresponding generation number.
|
1998-09-15 06:23:21 +00:00
|
|
|
The
|
|
|
|
.Va numdevs
|
2001-07-15 07:53:42 +00:00
|
|
|
subelement of the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt devinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
structure contains the current
|
|
|
|
number of devices registered with the kernel
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
1998-09-15 06:23:21 +00:00
|
|
|
subsystem.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
selects devices to display based upon a number of criteria:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width indent
|
1998-09-15 06:23:21 +00:00
|
|
|
.It specified devices
|
2001-08-04 18:25:48 +00:00
|
|
|
Specified devices are the first selection priority.
|
2005-06-30 06:35:51 +00:00
|
|
|
These are generally devices specified by name by the user e.g.\&
|
|
|
|
.Li da0 , da1 , cd0 .
|
1998-09-15 06:23:21 +00:00
|
|
|
.It match patterns
|
|
|
|
These are pattern matching expressions generated by
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_buildmatch
|
1998-09-15 06:23:21 +00:00
|
|
|
from user input.
|
|
|
|
.It performance
|
|
|
|
If performance mode is enabled, devices will be sorted based on the
|
|
|
|
.Va bytes
|
2001-07-15 07:53:42 +00:00
|
|
|
field in the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt device_selection
|
1998-09-15 06:23:21 +00:00
|
|
|
structure passed in to
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs .
|
2001-07-15 07:53:42 +00:00
|
|
|
The
|
1998-09-15 06:23:21 +00:00
|
|
|
.Va bytes
|
2001-08-04 18:25:48 +00:00
|
|
|
value currently must be maintained by the user.
|
|
|
|
In the future, this may be done for him in a
|
1998-09-15 06:23:21 +00:00
|
|
|
.Nm
|
|
|
|
library routine.
|
|
|
|
If no devices have been selected by name or by pattern, the performance
|
|
|
|
tracking code will select every device in the system, and sort them by
|
2001-08-04 18:25:48 +00:00
|
|
|
performance.
|
|
|
|
If devices have been selected by name or pattern, the performance tracking
|
|
|
|
code will honor those selections and will only sort among the selected
|
|
|
|
devices.
|
1998-09-15 06:23:21 +00:00
|
|
|
.It order in the devstat list
|
2005-06-30 06:35:51 +00:00
|
|
|
If the selection mode is set to
|
|
|
|
.Dv DS_SELECT_ADD ,
|
|
|
|
and if there are still less
|
2001-07-15 07:53:42 +00:00
|
|
|
than
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa maxshowdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
devices selected,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2001-07-15 07:53:42 +00:00
|
|
|
will automatically select up to
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa maxshowdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
devices.
|
|
|
|
.El
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
performs selections in four different modes:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width ".Dv DS_SELECT_ADDONLY"
|
|
|
|
.It Dv DS_SELECT_ADD
|
|
|
|
In
|
|
|
|
.Dq add
|
|
|
|
mode,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
will select any unselected devices specified by name or matching pattern.
|
|
|
|
It will also select more devices, in devstat list order, until the number
|
2001-07-15 07:53:42 +00:00
|
|
|
of selected devices is equal to
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa maxshowdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
or until all devices are
|
|
|
|
selected.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DS_SELECT_ONLY
|
|
|
|
In
|
|
|
|
.Dq only
|
|
|
|
mode,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
will clear all current selections, and will only select devices specified
|
|
|
|
by name or by matching pattern.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DS_SELECT_REMOVE
|
|
|
|
In
|
|
|
|
.Dq remove
|
|
|
|
mode,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
|
|
|
will remove devices specified by name or by matching pattern.
|
|
|
|
It will not select any additional devices.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DS_SELECT_ADDONLY
|
|
|
|
In
|
|
|
|
.Dq "add only"
|
|
|
|
mode,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
will select any unselected devices specified by name or matching pattern.
|
2005-06-30 06:35:51 +00:00
|
|
|
In this respect it is identical to
|
|
|
|
.Dq add
|
|
|
|
mode.
|
2001-08-04 18:25:48 +00:00
|
|
|
It will not, however, select any devices other than those specified.
|
1998-09-15 06:23:21 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
In all selection modes,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2001-07-15 07:53:42 +00:00
|
|
|
will not select any more than
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa maxshowdevs
|
2001-08-04 18:25:48 +00:00
|
|
|
devices.
|
|
|
|
One exception to this is when you are in
|
1998-09-15 06:23:21 +00:00
|
|
|
.Dq top
|
2001-08-04 18:25:48 +00:00
|
|
|
mode and no devices have been selected.
|
|
|
|
In this case,
|
|
|
|
.Fn devstat_selectdevs
|
|
|
|
will select every device in the system.
|
|
|
|
Client programs must pay attention to selection order when deciding whether
|
|
|
|
to pay attention to a particular device.
|
|
|
|
This may be the wrong behavior, and probably requires additional thought.
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
2001-07-15 07:53:42 +00:00
|
|
|
handles allocation and resizing of the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa dev_select
|
1998-09-15 06:23:21 +00:00
|
|
|
structure passed in
|
|
|
|
by the client.
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
2001-07-15 07:53:42 +00:00
|
|
|
uses the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa numdevs
|
2001-07-15 07:53:42 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current_generation
|
1998-09-15 06:23:21 +00:00
|
|
|
fields to track the
|
|
|
|
current
|
|
|
|
.Nm
|
2001-08-04 18:25:48 +00:00
|
|
|
generation and number of devices.
|
|
|
|
If
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa num_selections
|
1998-09-15 06:23:21 +00:00
|
|
|
is not the same
|
2001-07-15 07:53:42 +00:00
|
|
|
as
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa numdevs
|
2001-07-15 07:53:42 +00:00
|
|
|
or if
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa select_generation
|
2001-07-15 07:53:42 +00:00
|
|
|
is not the same as
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current_generation ,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
will resize the selection list as necessary, and re-initialize the
|
|
|
|
selection array.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_buildmatch
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
|
|
|
takes a comma separated match string and compiles it into a
|
|
|
|
.Vt devstat_match
|
|
|
|
structure that is understood by
|
|
|
|
.Fn devstat_selectdevs .
|
1998-09-15 06:23:21 +00:00
|
|
|
Match strings have the following format:
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
.D1 Ar device , Ns Ar type , Ns Ar if
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_buildmatch
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
takes care of allocating and reallocating the match list as necessary.
|
|
|
|
Currently known match types include:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width indent
|
1998-09-15 06:23:21 +00:00
|
|
|
.It device type:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width ".Li enclosure" -compact
|
|
|
|
.It Li da
|
1998-09-15 06:23:21 +00:00
|
|
|
Direct Access devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li sa
|
1998-09-15 06:23:21 +00:00
|
|
|
Sequential Access devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li printer
|
1998-09-15 06:23:21 +00:00
|
|
|
Printers
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li proc
|
1998-09-15 06:23:21 +00:00
|
|
|
Processor devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li worm
|
1998-09-15 06:23:21 +00:00
|
|
|
Write Once Read Multiple devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li cd
|
1998-09-15 06:23:21 +00:00
|
|
|
CD devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li scanner
|
1998-09-15 06:23:21 +00:00
|
|
|
Scanner devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li optical
|
1998-09-15 06:23:21 +00:00
|
|
|
Optical Memory devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li changer
|
1998-09-15 06:23:21 +00:00
|
|
|
Medium Changer devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li comm
|
1998-09-15 06:23:21 +00:00
|
|
|
Communication devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li array
|
1998-09-15 06:23:21 +00:00
|
|
|
Storage Array devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li enclosure
|
1998-09-15 06:23:21 +00:00
|
|
|
Enclosure Services devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li floppy
|
1998-09-15 06:23:21 +00:00
|
|
|
Floppy devices
|
|
|
|
.El
|
|
|
|
.It interface:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width ".Li enclosure" -compact
|
|
|
|
.It Li IDE
|
1998-09-15 06:23:21 +00:00
|
|
|
Integrated Drive Electronics devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li SCSI
|
1998-09-15 06:23:21 +00:00
|
|
|
Small Computer System Interface devices
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Li other
|
1998-09-15 06:23:21 +00:00
|
|
|
Any other device interface
|
|
|
|
.El
|
|
|
|
.It passthrough:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width ".Li enclosure" -compact
|
|
|
|
.It Li pass
|
1998-09-15 06:23:21 +00:00
|
|
|
Passthrough devices
|
|
|
|
.El
|
|
|
|
.El
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_compute_statistics
|
2005-08-10 00:51:36 +00:00
|
|
|
function provides complete statistics calculation.
|
2005-06-30 06:35:51 +00:00
|
|
|
There are four arguments for which values
|
|
|
|
.Em must
|
|
|
|
be supplied:
|
|
|
|
.Fa current ,
|
|
|
|
.Fa previous ,
|
|
|
|
.Fa etime ,
|
2001-08-04 18:25:48 +00:00
|
|
|
and the terminating argument for the varargs list,
|
2005-06-30 06:35:51 +00:00
|
|
|
.Dv DSM_NONE .
|
|
|
|
For most applications, the user will want to supply valid
|
|
|
|
.Vt devstat
|
2001-08-04 18:25:48 +00:00
|
|
|
structures for both
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current
|
1998-09-15 06:23:21 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous .
|
2001-08-04 18:25:48 +00:00
|
|
|
In some instances, for instance when calculating statistics since system
|
2005-06-30 06:35:51 +00:00
|
|
|
boot, the user may pass in a
|
|
|
|
.Dv NULL
|
|
|
|
pointer for the
|
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
argument.
|
|
|
|
In that case,
|
|
|
|
.Fn devstat_compute_statistics
|
|
|
|
will use the total stats in the
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current
|
2001-08-04 18:25:48 +00:00
|
|
|
structure to calculate statistics over
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa etime .
|
|
|
|
For each statistics to be calculated, the user should supply the proper
|
2001-08-04 18:25:48 +00:00
|
|
|
enumerated type (listed below), and a variable of the indicated type.
|
2005-06-30 06:35:51 +00:00
|
|
|
All statistics are either integer values, for which a
|
|
|
|
.Vt u_int64_t
|
|
|
|
is used,
|
|
|
|
or floating point, for which a
|
|
|
|
.Vt "long double"
|
|
|
|
is used.
|
2001-08-04 18:25:48 +00:00
|
|
|
The statistics that may be calculated are:
|
2005-06-30 06:35:51 +00:00
|
|
|
.Bl -tag -width ".Dv DSM_TRANSFERS_PER_SECOND_OTHER"
|
|
|
|
.It Dv DSM_NONE
|
2001-08-04 18:25:48 +00:00
|
|
|
type: N/A
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
This
|
|
|
|
.Em must
|
2001-08-04 18:25:48 +00:00
|
|
|
be the last argument passed to
|
|
|
|
.Fn devstat_compute_statistics .
|
|
|
|
It is an argument list terminator.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_TOTAL_BYTES
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The total number of bytes transferred between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TOTAL_BYTES_READ
|
|
|
|
.It Dv DSM_TOTAL_BYTES_WRITE
|
|
|
|
.It Dv DSM_TOTAL_BYTES_FREE
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The total number of bytes in transactions of the specified type
|
|
|
|
between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TOTAL_TRANSFERS
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The total number of transfers between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TOTAL_TRANSFERS_OTHER
|
|
|
|
.It Dv DSM_TOTAL_TRANSFERS_READ
|
|
|
|
.It Dv DSM_TOTAL_TRANSFERS_WRITE
|
|
|
|
.It Dv DSM_TOTAL_TRANSFERS_FREE
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The total number of transactions of the specified type between
|
|
|
|
the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TOTAL_BLOCKS
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The total number of blocks transferred between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
2001-08-04 18:25:48 +00:00
|
|
|
This number is in terms of the blocksize reported by the device.
|
2004-07-02 23:52:20 +00:00
|
|
|
If no blocksize has been reported (i.e., the block size is 0), a default
|
2001-08-04 18:25:48 +00:00
|
|
|
blocksize of 512 bytes will be used in the calculation.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_TOTAL_BLOCKS_READ
|
|
|
|
.It Dv DSM_TOTAL_BLOCKS_WRITE
|
|
|
|
.It Dv DSM_TOTAL_BLOCKS_FREE
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The total number of blocks of the specified type between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
2001-08-04 18:25:48 +00:00
|
|
|
This number is in terms of the blocksize reported by the device.
|
2004-07-02 23:52:20 +00:00
|
|
|
If no blocksize has been reported (i.e., the block size is 0), a default
|
2001-08-04 18:25:48 +00:00
|
|
|
blocksize of 512 bytes will be used in the calculation.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_KB_PER_TRANSFER
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The average number of kilobytes per transfer between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_KB_PER_TRANSFER_READ
|
|
|
|
.It Dv DSM_KB_PER_TRANSFER_WRITE
|
|
|
|
.It Dv DSM_KB_PER_TRANSFER_FREE
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The average number of kilobytes in the specified type transaction between
|
|
|
|
the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TRANSFERS_PER_SECOND
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The average number of transfers per second between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_TRANSFERS_PER_SECOND_OTHER
|
|
|
|
.It Dv DSM_TRANSFERS_PER_SECOND_READ
|
|
|
|
.It Dv DSM_TRANSFERS_PER_SECOND_WRITE
|
|
|
|
.It Dv DSM_TRANSFERS_PER_SECOND_FREE
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The average number of transactions of the specified type per second
|
|
|
|
between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_MB_PER_SECOND
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The average number of megabytes transferred per second between the
|
|
|
|
acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_MB_PER_SECOND_READ
|
|
|
|
.It Dv DSM_MB_PER_SECOND_WRITE
|
|
|
|
.It Dv DSM_MB_PER_SECOND_FREE
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-05-22 13:02:28 +00:00
|
|
|
The average number of megabytes per second in the specified type of
|
2003-03-18 13:45:08 +00:00
|
|
|
transaction between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_BLOCKS_PER_SECOND
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
|
|
|
The average number of blocks transferred per second between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
2001-08-04 18:25:48 +00:00
|
|
|
This number is in terms of the blocksize reported by the device.
|
2004-07-02 23:52:20 +00:00
|
|
|
If no blocksize has been reported (i.e., the block size is 0), a default
|
2001-08-04 18:25:48 +00:00
|
|
|
blocksize of 512 bytes will be used in the calculation.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_BLOCKS_PER_SECOND_READ
|
|
|
|
.It Dv DSM_BLOCKS_PER_SECOND_WRITE
|
|
|
|
.It Dv DSM_BLOCKS_PER_SECOND_FREE
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2010-08-03 17:40:09 +00:00
|
|
|
The average number of blocks per second in the specified type of transaction
|
2003-03-18 13:45:08 +00:00
|
|
|
between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
2001-08-04 18:25:48 +00:00
|
|
|
This number is in terms of the blocksize reported by the device.
|
2004-07-02 23:52:20 +00:00
|
|
|
If no blocksize has been reported (i.e., the block size is 0), a default
|
2001-08-04 18:25:48 +00:00
|
|
|
blocksize of 512 bytes will be used in the calculation.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_MS_PER_TRANSACTION
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The average duration of transactions between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_MS_PER_TRANSACTION_OTHER
|
|
|
|
.It Dv DSM_MS_PER_TRANSACTION_READ
|
|
|
|
.It Dv DSM_MS_PER_TRANSACTION_WRITE
|
|
|
|
.It Dv DSM_MS_PER_TRANSACTION_FREE
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The average duration of transactions of the specified type between the
|
|
|
|
acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_BUSY_PCT
|
|
|
|
type:
|
|
|
|
.Vt "long double *"
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
2003-03-18 13:45:08 +00:00
|
|
|
The percentage of time the device had one or more transactions outstanding
|
|
|
|
between the acquisition of
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa previous
|
2001-08-04 18:25:48 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current .
|
|
|
|
.It Dv DSM_QUEUE_LENGTH
|
|
|
|
type:
|
|
|
|
.Vt "u_int64_t *"
|
2003-03-18 13:45:08 +00:00
|
|
|
.Pp
|
|
|
|
The number of not yet completed transactions at the time when
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa current
|
2003-03-18 13:45:08 +00:00
|
|
|
was acquired.
|
2005-06-30 06:35:51 +00:00
|
|
|
.It Dv DSM_SKIP
|
2001-08-18 05:46:59 +00:00
|
|
|
type: N/A
|
|
|
|
.Pp
|
|
|
|
If you do not need a result from
|
|
|
|
.Fn devstat_compute_statistics ,
|
|
|
|
just put
|
2005-06-30 06:35:51 +00:00
|
|
|
.Dv DSM_SKIP
|
2001-08-18 05:46:59 +00:00
|
|
|
as first (type) parameter and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Dv NULL
|
2001-08-18 05:46:59 +00:00
|
|
|
as second parameter.
|
|
|
|
This can be useful in scenarios where the statistics to be calculated
|
|
|
|
are determined at run time.
|
2001-08-04 18:25:48 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
2005-07-17 13:33:04 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_compute_etime
|
2005-07-17 13:33:04 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
provides an easy way to find the difference in seconds between two
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt bintime
|
2001-08-04 18:25:48 +00:00
|
|
|
structures.
|
|
|
|
This is most commonly used in conjunction with the time recorded by the
|
|
|
|
.Fn devstat_getdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function (in
|
|
|
|
.Vt "struct statinfo" )
|
1998-09-15 06:23:21 +00:00
|
|
|
each time it fetches the current
|
|
|
|
.Nm
|
|
|
|
list.
|
|
|
|
.Sh RETURN VALUES
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getnumdevs ,
|
|
|
|
.Fn devstat_getgeneration ,
|
1998-09-15 06:23:21 +00:00
|
|
|
and
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getversion
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
|
|
|
return the indicated sysctl variable, or \-1 if there is an error
|
1998-09-15 06:23:21 +00:00
|
|
|
fetching the variable.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_checkversion
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
returns 0 if the kernel and userland
|
2000-11-20 14:08:07 +00:00
|
|
|
.Nm
|
2001-08-04 18:25:48 +00:00
|
|
|
versions match.
|
2005-06-30 06:35:51 +00:00
|
|
|
If they do not match, it returns \-1.
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
and
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
functions
|
|
|
|
return \-1 in case of an error, 0 if there is no error, and 1 if the device
|
2001-08-04 18:25:48 +00:00
|
|
|
list or selected devices have changed.
|
|
|
|
A return value of 1 from
|
|
|
|
.Fn devstat_getdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
is usually a hint to re-run
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
because the device list has changed.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_buildmatch
|
2005-06-30 06:35:51 +00:00
|
|
|
function returns \-1 for error, and 0 if there is no error.
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_compute_etime
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
returns the computed elapsed time.
|
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_compute_statistics
|
2005-06-30 06:35:51 +00:00
|
|
|
function returns \-1 for error, and 0 for success.
|
2001-08-04 18:25:48 +00:00
|
|
|
.Pp
|
1998-09-15 06:23:21 +00:00
|
|
|
If an error is returned from one of the
|
|
|
|
.Nm
|
|
|
|
library functions, the reason for the error is generally printed in
|
|
|
|
the global string
|
|
|
|
.Va devstat_errbuf
|
|
|
|
which is
|
|
|
|
.Dv DEVSTAT_ERRBUF_SIZE
|
|
|
|
characters long.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr systat 1 ,
|
2001-08-04 18:25:48 +00:00
|
|
|
.Xr kvm 3 ,
|
|
|
|
.Xr sysctl 3 ,
|
1998-09-15 06:23:21 +00:00
|
|
|
.Xr iostat 8 ,
|
|
|
|
.Xr rpc.rstatd 8 ,
|
2001-08-22 14:16:31 +00:00
|
|
|
.Xr sysctl 8 ,
|
1998-09-15 06:23:21 +00:00
|
|
|
.Xr vmstat 8 ,
|
|
|
|
.Xr devstat 9
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
statistics system first appeared in
|
|
|
|
.Fx 3.0 .
|
2005-06-30 06:35:51 +00:00
|
|
|
The new interface (the functions prefixed with
|
|
|
|
.Li devstat_ )
|
|
|
|
first appeared in
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fx 5.0 .
|
1998-09-15 06:23:21 +00:00
|
|
|
.Sh AUTHORS
|
2001-02-01 16:38:02 +00:00
|
|
|
.An Kenneth Merry Aq ken@FreeBSD.org
|
1998-09-15 06:23:21 +00:00
|
|
|
.Sh BUGS
|
|
|
|
There should probably be an interface to de-allocate memory allocated by
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_getdevs ,
|
|
|
|
.Fn devstat_selectdevs ,
|
1998-09-15 06:23:21 +00:00
|
|
|
and
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_buildmatch .
|
1998-09-15 06:23:21 +00:00
|
|
|
.Pp
|
2005-06-30 06:35:51 +00:00
|
|
|
The
|
2001-08-04 18:25:48 +00:00
|
|
|
.Fn devstat_selectdevs
|
2005-06-30 06:35:51 +00:00
|
|
|
function
|
1998-09-15 06:23:21 +00:00
|
|
|
should probably not select more than
|
2005-06-30 06:35:51 +00:00
|
|
|
.Fa maxshowdevs
|
1998-09-15 06:23:21 +00:00
|
|
|
devices in
|
|
|
|
.Dq top
|
|
|
|
mode when no devices have been selected previously.
|
|
|
|
.Pp
|
|
|
|
There should probably be functions to perform the statistics buffer
|
|
|
|
swapping that goes on in most of the clients of this library.
|
|
|
|
.Pp
|
|
|
|
The
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt statinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
and
|
2005-06-30 06:35:51 +00:00
|
|
|
.Vt devinfo
|
1998-09-15 06:23:21 +00:00
|
|
|
structures should probably be cleaned up and thought out a little more.
|