xref: /freebsd/lib/libdevstat/devstat.3 (revision fdd6757e713945cdb16ab346580332de933a00bc)
128fb27baSJustin T. Gibbs.\"
2c4a5ef6eSThomas Moestl.\" Copyright (c) 1998, 1999, 2001 Kenneth D. Merry.
328fb27baSJustin T. Gibbs.\" All rights reserved.
428fb27baSJustin T. Gibbs.\"
528fb27baSJustin T. Gibbs.\" Redistribution and use in source and binary forms, with or without
628fb27baSJustin T. Gibbs.\" modification, are permitted provided that the following conditions
728fb27baSJustin T. Gibbs.\" are met:
828fb27baSJustin T. Gibbs.\" 1. Redistributions of source code must retain the above copyright
928fb27baSJustin T. Gibbs.\"    notice, this list of conditions and the following disclaimer.
1028fb27baSJustin T. Gibbs.\" 2. Redistributions in binary form must reproduce the above copyright
1128fb27baSJustin T. Gibbs.\"    notice, this list of conditions and the following disclaimer in the
1228fb27baSJustin T. Gibbs.\"    documentation and/or other materials provided with the distribution.
1328fb27baSJustin T. Gibbs.\" 3. The name of the author may not be used to endorse or promote products
1428fb27baSJustin T. Gibbs.\"    derived from this software without specific prior written permission.
1528fb27baSJustin T. Gibbs.\"
1628fb27baSJustin T. Gibbs.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1728fb27baSJustin T. Gibbs.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1828fb27baSJustin T. Gibbs.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1928fb27baSJustin T. Gibbs.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2028fb27baSJustin T. Gibbs.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2128fb27baSJustin T. Gibbs.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2228fb27baSJustin T. Gibbs.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2328fb27baSJustin T. Gibbs.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2428fb27baSJustin T. Gibbs.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2528fb27baSJustin T. Gibbs.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2628fb27baSJustin T. Gibbs.\" SUCH DAMAGE.
2728fb27baSJustin T. Gibbs.\"
287f3dea24SPeter Wemm.\" $FreeBSD$
2928fb27baSJustin T. Gibbs.\"
30*fdd6757eSMikolaj Golub.Dd December 15, 2012
3128fb27baSJustin T. Gibbs.Dt DEVSTAT 3
32a307d598SRuslan Ermilov.Os
3328fb27baSJustin T. Gibbs.Sh NAME
34b27e4ff3SAlexey Zelkin.Nm devstat ,
35c4a5ef6eSThomas Moestl.Nm devstat_getnumdevs ,
36c4a5ef6eSThomas Moestl.Nm devstat_getgeneration ,
37c4a5ef6eSThomas Moestl.Nm devstat_getversion ,
38c4a5ef6eSThomas Moestl.Nm devstat_checkversion ,
39c4a5ef6eSThomas Moestl.Nm devstat_getdevs ,
40c4a5ef6eSThomas Moestl.Nm devstat_selectdevs ,
41c4a5ef6eSThomas Moestl.Nm devstat_buildmatch ,
42c4a5ef6eSThomas Moestl.Nm devstat_compute_statistics ,
433a5146d9SRuslan Ermilov.Nm devstat_compute_etime
4428fb27baSJustin T. Gibbs.Nd device statistics utility library
459d5b4f83SAlexey Zelkin.Sh LIBRARY
469d5b4f83SAlexey Zelkin.Lb libdevstat
4728fb27baSJustin T. Gibbs.Sh SYNOPSIS
4832eef9aeSRuslan Ermilov.In devstat.h
4928fb27baSJustin T. Gibbs.Ft int
508b7475edSRuslan Ermilov.Fn devstat_getnumdevs "kvm_t *kd"
51c4a5ef6eSThomas Moestl.Ft long
528b7475edSRuslan Ermilov.Fn devstat_getgeneration "kvm_t *kd"
53c4a5ef6eSThomas Moestl.Ft int
548b7475edSRuslan Ermilov.Fn devstat_getversion "kvm_t *kd"
55c4a5ef6eSThomas Moestl.Ft int
568b7475edSRuslan Ermilov.Fn devstat_checkversion "kvm_t *kd"
57c4a5ef6eSThomas Moestl.Ft int
588b7475edSRuslan Ermilov.Fn devstat_getdevs "kvm_t *kd" "struct statinfo *stats"
59c4a5ef6eSThomas Moestl.Ft int
60c4a5ef6eSThomas Moestl.Fo devstat_selectdevs
61c4a5ef6eSThomas Moestl.Fa "struct device_selection **dev_select"
62c4a5ef6eSThomas Moestl.Fa "int *num_selected"
63c4a5ef6eSThomas Moestl.Fa "int *num_selections"
64c4a5ef6eSThomas Moestl.Fa "long *select_generation"
65c4a5ef6eSThomas Moestl.Fa "long current_generation"
66c4a5ef6eSThomas Moestl.Fa "struct devstat *devices"
67c4a5ef6eSThomas Moestl.Fa "int numdevs"
68c4a5ef6eSThomas Moestl.Fa "struct devstat_match *matches"
69c4a5ef6eSThomas Moestl.Fa "int num_matches"
70c4a5ef6eSThomas Moestl.Fa "char **dev_selections"
71c4a5ef6eSThomas Moestl.Fa "int num_dev_selections"
72c4a5ef6eSThomas Moestl.Fa "devstat_select_mode select_mode"
73c4a5ef6eSThomas Moestl.Fa "int maxshowdevs"
74c4a5ef6eSThomas Moestl.Fa "int perf_select"
75c4a5ef6eSThomas Moestl.Fc
76c4a5ef6eSThomas Moestl.Ft int
77c4a5ef6eSThomas Moestl.Fo devstat_buildmatch
78c4a5ef6eSThomas Moestl.Fa "char *match_str"
79c4a5ef6eSThomas Moestl.Fa "struct devstat_match **matches"
80c4a5ef6eSThomas Moestl.Fa "int *num_matches"
81c4a5ef6eSThomas Moestl.Fc
82c4a5ef6eSThomas Moestl.Ft int
83c4a5ef6eSThomas Moestl.Fo devstat_compute_statistics
84c4a5ef6eSThomas Moestl.Fa "struct devstat *current"
85c4a5ef6eSThomas Moestl.Fa "struct devstat *previous"
860f393d5cSBruce Evans.Fa "long double etime"
87c4a5ef6eSThomas Moestl.Fa "..."
88c4a5ef6eSThomas Moestl.Fc
898b7475edSRuslan Ermilov.Ft "long double"
90634eb5fbSPhilippe Charnier.Fo devstat_compute_etime
91634eb5fbSPhilippe Charnier.Fa "struct bintime *cur_time"
92634eb5fbSPhilippe Charnier.Fa "struct bintime *prev_time"
93634eb5fbSPhilippe Charnier.Fc
9428fb27baSJustin T. Gibbs.Sh DESCRIPTION
9528fb27baSJustin T. GibbsThe
9628fb27baSJustin T. Gibbs.Nm
9728fb27baSJustin T. Gibbslibrary is a library of helper functions for dealing with the kernel
9828fb27baSJustin T. Gibbs.Xr devstat 9
9928fb27baSJustin T. Gibbsinterface, which is accessible to users via
100c4a5ef6eSThomas Moestl.Xr sysctl 3
101c4a5ef6eSThomas Moestland
102c4a5ef6eSThomas Moestl.Xr kvm 3 .
103b9154997SKenneth D. MerryAll functions that take a
1048b7475edSRuslan Ermilov.Vt "kvm_t *"
105c4a5ef6eSThomas Moestlas first argument can be passed
106c4a5ef6eSThomas Moestl.Dv NULL
107c4a5ef6eSThomas Moestlinstead of a kvm handle as this argument,
108c4a5ef6eSThomas Moestlwhich causes the data to be read via
10928fb27baSJustin T. Gibbs.Xr sysctl 3 .
110c4a5ef6eSThomas MoestlOtherwise, it is read via
111c4a5ef6eSThomas Moestl.Xr kvm 3
112c4a5ef6eSThomas Moestlusing the supplied handle.
1138b7475edSRuslan ErmilovThe
114c4a5ef6eSThomas Moestl.Fn devstat_checkversion
1158b7475edSRuslan Ermilovfunction
116c4a5ef6eSThomas Moestlshould be called with each kvm handle that is going to be used (or with
117c4a5ef6eSThomas Moestl.Dv NULL
118c4a5ef6eSThomas Moestlif
119c4a5ef6eSThomas Moestl.Xr sysctl 3
120c4a5ef6eSThomas Moestlis going to be used).
12128fb27baSJustin T. Gibbs.Pp
1228b7475edSRuslan ErmilovThe
123c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs
1248b7475edSRuslan Ermilovfunction
12528fb27baSJustin T. Gibbsreturns the number of devices registered with the
1263b8ecdbbSRuslan Ermilov.Nm
12728fb27baSJustin T. Gibbssubsystem in the kernel.
12828fb27baSJustin T. Gibbs.Pp
1298b7475edSRuslan ErmilovThe
130c4a5ef6eSThomas Moestl.Fn devstat_getgeneration
1318b7475edSRuslan Ermilovfunction
13228fb27baSJustin T. Gibbsreturns the current generation of the
1333b8ecdbbSRuslan Ermilov.Nm
13428fb27baSJustin T. Gibbslist of devices in the kernel.
13528fb27baSJustin T. Gibbs.Pp
1368b7475edSRuslan ErmilovThe
137c4a5ef6eSThomas Moestl.Fn devstat_getversion
1388b7475edSRuslan Ermilovfunction
13928fb27baSJustin T. Gibbsreturns the current kernel
1403b8ecdbbSRuslan Ermilov.Nm
14128fb27baSJustin T. Gibbsversion.
14228fb27baSJustin T. Gibbs.Pp
1438b7475edSRuslan ErmilovThe
144c4a5ef6eSThomas Moestl.Fn devstat_checkversion
1458b7475edSRuslan Ermilovfunction
1468b7475edSRuslan Ermilovchecks the userland
1478b7475edSRuslan Ermilov.Nm
1488b7475edSRuslan Ermilovversion against the kernel
1498b7475edSRuslan Ermilov.Nm
1508b7475edSRuslan Ermilovversion.
151c4a5ef6eSThomas MoestlIf the two are identical, it returns zero.
152c4a5ef6eSThomas MoestlOtherwise, it prints an appropriate error in
15328fb27baSJustin T. Gibbs.Va devstat_errbuf
1548b7475edSRuslan Ermilovand returns \-1.
15528fb27baSJustin T. Gibbs.Pp
1568b7475edSRuslan ErmilovThe
157c4a5ef6eSThomas Moestl.Fn devstat_getdevs
1588b7475edSRuslan Ermilovfunction
15928fb27baSJustin T. Gibbsfetches the current list of devices and statistics into the supplied
1608b7475edSRuslan Ermilov.Vt statinfo
161c4a5ef6eSThomas Moestlstructure.
162c4a5ef6eSThomas MoestlThe
1638b7475edSRuslan Ermilov.Vt statinfo
16428fb27baSJustin T. Gibbsstructure can be found in
165fe08efe6SRuslan Ermilov.In devstat.h :
16628fb27baSJustin T. Gibbs.Bd -literal -offset indent
16728fb27baSJustin T. Gibbsstruct statinfo {
16828fb27baSJustin T. Gibbs	long            cp_time[CPUSTATES];
16928fb27baSJustin T. Gibbs	long            tk_nin;
17028fb27baSJustin T. Gibbs	long            tk_nout;
17128fb27baSJustin T. Gibbs	struct devinfo  *dinfo;
172b193011aSPoul-Henning Kamp	long double     snap_time;
17328fb27baSJustin T. Gibbs};
17428fb27baSJustin T. Gibbs.Ed
17528fb27baSJustin T. Gibbs.Pp
1768b7475edSRuslan ErmilovThe
177c4a5ef6eSThomas Moestl.Fn devstat_getdevs
1788b7475edSRuslan Ermilovfunction
17928fb27baSJustin T. Gibbsexpects the
1808b7475edSRuslan Ermilov.Vt statinfo
18128fb27baSJustin T. Gibbsstructure to be allocated, and it also expects the
18228fb27baSJustin T. Gibbs.Va dinfo
1836f83979dSKenneth D. Merrysubelement to be allocated and zeroed prior to the first invocation of
184c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
1856f83979dSKenneth D. MerryThe
1866f83979dSKenneth D. Merry.Va dinfo
1876f83979dSKenneth D. Merrysubelement is used to store state between calls, and should not be modified
1886f83979dSKenneth D. Merryafter the first call to
189c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
1906f83979dSKenneth D. MerryThe
19128fb27baSJustin T. Gibbs.Va dinfo
19228fb27baSJustin T. Gibbssubelement contains the following elements:
19328fb27baSJustin T. Gibbs.Bd -literal -offset indent
19428fb27baSJustin T. Gibbsstruct devinfo {
19528fb27baSJustin T. Gibbs	struct devstat	*devices;
1966b99842aSEd Schouten	uint8_t		*mem_ptr;
197bcc6a3daSKenneth D. Merry	long		generation;
19828fb27baSJustin T. Gibbs	int		numdevs;
19928fb27baSJustin T. Gibbs};
20028fb27baSJustin T. Gibbs.Ed
20128fb27baSJustin T. Gibbs.Pp
20228fb27baSJustin T. GibbsThe
20328fb27baSJustin T. Gibbs.Va kern.devstat.all
2048b7475edSRuslan Ermilov.Xr sysctl 8
20528fb27baSJustin T. Gibbsvariable contains an array of
2063b8ecdbbSRuslan Ermilov.Nm
20728fb27baSJustin T. Gibbsstructures, but at the head of the array is the current
2083b8ecdbbSRuslan Ermilov.Nm
209c4a5ef6eSThomas Moestlgeneration.
210c4a5ef6eSThomas MoestlThe reason the generation is at the head of the buffer is so that userland
2118b7475edSRuslan Ermilovsoftware accessing the
2128b7475edSRuslan Ermilov.Nm
2138b7475edSRuslan Ermilovstatistics information can atomically get
214c4a5ef6eSThomas Moestlboth the statistics information and the corresponding generation number.
215c4a5ef6eSThomas MoestlIf client software were forced to get the generation number via a separate
2168b7475edSRuslan Ermilov.Xr sysctl 8
21728fb27baSJustin T. Gibbsvariable (which is available for convenience), the list of devices could
21828fb27baSJustin T. Gibbschange between the time the client gets the generation and the time the
21928fb27baSJustin T. Gibbsclient gets the device list.
22028fb27baSJustin T. Gibbs.Pp
22128fb27baSJustin T. GibbsThe
22228fb27baSJustin T. Gibbs.Va mem_ptr
22328fb27baSJustin T. Gibbssubelement of the
2248b7475edSRuslan Ermilov.Vt devinfo
22528fb27baSJustin T. Gibbsstructure is a pointer to memory that is allocated, and resized if
22628fb27baSJustin T. Gibbsnecessary, by
227c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
22828fb27baSJustin T. GibbsThe devices subelement of the
2298b7475edSRuslan Ermilov.Vt devinfo
23028fb27baSJustin T. Gibbsstructure is basically a pointer to the beginning of the array of devstat
23128fb27baSJustin T. Gibbsstructures from the
23228fb27baSJustin T. Gibbs.Va kern.devstat.all
2338b7475edSRuslan Ermilov.Xr sysctl 8
234c4a5ef6eSThomas Moestlvariable (or the corresponding values read via
235c4a5ef6eSThomas Moestl.Xr kvm 3 ) .
236c4a5ef6eSThomas MoestlThe generation subelement of the
2378b7475edSRuslan Ermilov.Vt devinfo
238c4a5ef6eSThomas Moestlstructure contains the corresponding generation number.
23928fb27baSJustin T. GibbsThe
24028fb27baSJustin T. Gibbs.Va numdevs
24128fb27baSJustin T. Gibbssubelement of the
2428b7475edSRuslan Ermilov.Vt devinfo
24328fb27baSJustin T. Gibbsstructure contains the current
24428fb27baSJustin T. Gibbsnumber of devices registered with the kernel
2453b8ecdbbSRuslan Ermilov.Nm
24628fb27baSJustin T. Gibbssubsystem.
24728fb27baSJustin T. Gibbs.Pp
2488b7475edSRuslan ErmilovThe
249c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
2508b7475edSRuslan Ermilovfunction
25128fb27baSJustin T. Gibbsselects devices to display based upon a number of criteria:
2528b7475edSRuslan Ermilov.Bl -tag -width indent
25328fb27baSJustin T. Gibbs.It specified devices
254c4a5ef6eSThomas MoestlSpecified devices are the first selection priority.
2558b7475edSRuslan ErmilovThese are generally devices specified by name by the user e.g.\&
2568b7475edSRuslan Ermilov.Li da0 , da1 , cd0 .
25728fb27baSJustin T. Gibbs.It match patterns
25828fb27baSJustin T. GibbsThese are pattern matching expressions generated by
259c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
26028fb27baSJustin T. Gibbsfrom user input.
26128fb27baSJustin T. Gibbs.It performance
26228fb27baSJustin T. GibbsIf performance mode is enabled, devices will be sorted based on the
26328fb27baSJustin T. Gibbs.Va bytes
26428fb27baSJustin T. Gibbsfield in the
2658b7475edSRuslan Ermilov.Vt device_selection
26628fb27baSJustin T. Gibbsstructure passed in to
267c4a5ef6eSThomas Moestl.Fn devstat_selectdevs .
26828fb27baSJustin T. GibbsThe
26928fb27baSJustin T. Gibbs.Va bytes
270c4a5ef6eSThomas Moestlvalue currently must be maintained by the user.
271c4a5ef6eSThomas MoestlIn the future, this may be done for him in a
27228fb27baSJustin T. Gibbs.Nm
27328fb27baSJustin T. Gibbslibrary routine.
27428fb27baSJustin T. GibbsIf no devices have been selected by name or by pattern, the performance
27528fb27baSJustin T. Gibbstracking code will select every device in the system, and sort them by
276c4a5ef6eSThomas Moestlperformance.
277c4a5ef6eSThomas MoestlIf devices have been selected by name or pattern, the performance tracking
278c4a5ef6eSThomas Moestlcode will honor those selections and will only sort among the selected
279c4a5ef6eSThomas Moestldevices.
28028fb27baSJustin T. Gibbs.It order in the devstat list
2818b7475edSRuslan ErmilovIf the selection mode is set to
2828b7475edSRuslan Ermilov.Dv DS_SELECT_ADD ,
2838b7475edSRuslan Ermilovand if there are still less
28428fb27baSJustin T. Gibbsthan
2858b7475edSRuslan Ermilov.Fa maxshowdevs
28628fb27baSJustin T. Gibbsdevices selected,
287c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
28828fb27baSJustin T. Gibbswill automatically select up to
2898b7475edSRuslan Ermilov.Fa maxshowdevs
29028fb27baSJustin T. Gibbsdevices.
29128fb27baSJustin T. Gibbs.El
29228fb27baSJustin T. Gibbs.Pp
2938b7475edSRuslan ErmilovThe
294c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
2958b7475edSRuslan Ermilovfunction
29628fb27baSJustin T. Gibbsperforms selections in four different modes:
2978b7475edSRuslan Ermilov.Bl -tag -width ".Dv DS_SELECT_ADDONLY"
2988b7475edSRuslan Ermilov.It Dv DS_SELECT_ADD
2998b7475edSRuslan ErmilovIn
3008b7475edSRuslan Ermilov.Dq add
3018b7475edSRuslan Ermilovmode,
302c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
30328fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern.
30428fb27baSJustin T. GibbsIt will also select more devices, in devstat list order, until the number
30528fb27baSJustin T. Gibbsof selected devices is equal to
3068b7475edSRuslan Ermilov.Fa maxshowdevs
30728fb27baSJustin T. Gibbsor until all devices are
30828fb27baSJustin T. Gibbsselected.
3098b7475edSRuslan Ermilov.It Dv DS_SELECT_ONLY
3108b7475edSRuslan ErmilovIn
3118b7475edSRuslan Ermilov.Dq only
3128b7475edSRuslan Ermilovmode,
313c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
31428fb27baSJustin T. Gibbswill clear all current selections, and will only select devices specified
31528fb27baSJustin T. Gibbsby name or by matching pattern.
3168b7475edSRuslan Ermilov.It Dv DS_SELECT_REMOVE
3178b7475edSRuslan ErmilovIn
3188b7475edSRuslan Ermilov.Dq remove
3198b7475edSRuslan Ermilovmode,
320c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
321c4a5ef6eSThomas Moestlwill remove devices specified by name or by matching pattern.
322c4a5ef6eSThomas MoestlIt will not select any additional devices.
3238b7475edSRuslan Ermilov.It Dv DS_SELECT_ADDONLY
3248b7475edSRuslan ErmilovIn
3258b7475edSRuslan Ermilov.Dq "add only"
3268b7475edSRuslan Ermilovmode,
327c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
32828fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern.
3298b7475edSRuslan ErmilovIn this respect it is identical to
3308b7475edSRuslan Ermilov.Dq add
3318b7475edSRuslan Ermilovmode.
332c4a5ef6eSThomas MoestlIt will not, however, select any devices other than those specified.
33328fb27baSJustin T. Gibbs.El
33428fb27baSJustin T. Gibbs.Pp
33528fb27baSJustin T. GibbsIn all selection modes,
336c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
33728fb27baSJustin T. Gibbswill not select any more than
3388b7475edSRuslan Ermilov.Fa maxshowdevs
339c4a5ef6eSThomas Moestldevices.
340c4a5ef6eSThomas MoestlOne exception to this is when you are in
34128fb27baSJustin T. Gibbs.Dq top
342c4a5ef6eSThomas Moestlmode and no devices have been selected.
343c4a5ef6eSThomas MoestlIn this case,
344c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
345c4a5ef6eSThomas Moestlwill select every device in the system.
346c4a5ef6eSThomas MoestlClient programs must pay attention to selection order when deciding whether
347c4a5ef6eSThomas Moestlto pay attention to a particular device.
348c4a5ef6eSThomas MoestlThis may be the wrong behavior, and probably requires additional thought.
34928fb27baSJustin T. Gibbs.Pp
3508b7475edSRuslan ErmilovThe
351c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
3528b7475edSRuslan Ermilovfunction
35328fb27baSJustin T. Gibbshandles allocation and resizing of the
3548b7475edSRuslan Ermilov.Fa dev_select
35528fb27baSJustin T. Gibbsstructure passed in
35628fb27baSJustin T. Gibbsby the client.
3578b7475edSRuslan ErmilovThe
358c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
3598b7475edSRuslan Ermilovfunction
36028fb27baSJustin T. Gibbsuses the
3618b7475edSRuslan Ermilov.Fa numdevs
36228fb27baSJustin T. Gibbsand
3638b7475edSRuslan Ermilov.Fa current_generation
36428fb27baSJustin T. Gibbsfields to track the
36528fb27baSJustin T. Gibbscurrent
36628fb27baSJustin T. Gibbs.Nm
367c4a5ef6eSThomas Moestlgeneration and number of devices.
368c4a5ef6eSThomas MoestlIf
3698b7475edSRuslan Ermilov.Fa num_selections
37028fb27baSJustin T. Gibbsis not the same
37128fb27baSJustin T. Gibbsas
3728b7475edSRuslan Ermilov.Fa numdevs
37328fb27baSJustin T. Gibbsor if
3748b7475edSRuslan Ermilov.Fa select_generation
37528fb27baSJustin T. Gibbsis not the same as
3768b7475edSRuslan Ermilov.Fa current_generation ,
377c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
37828fb27baSJustin T. Gibbswill resize the selection list as necessary, and re-initialize the
37928fb27baSJustin T. Gibbsselection array.
38028fb27baSJustin T. Gibbs.Pp
3818b7475edSRuslan ErmilovThe
382c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
3838b7475edSRuslan Ermilovfunction
3848b7475edSRuslan Ermilovtakes a comma separated match string and compiles it into a
3858b7475edSRuslan Ermilov.Vt devstat_match
3868b7475edSRuslan Ermilovstructure that is understood by
3878b7475edSRuslan Ermilov.Fn devstat_selectdevs .
38828fb27baSJustin T. GibbsMatch strings have the following format:
38928fb27baSJustin T. Gibbs.Pp
3908b7475edSRuslan Ermilov.D1 Ar device , Ns Ar type , Ns Ar if
39128fb27baSJustin T. Gibbs.Pp
3928b7475edSRuslan ErmilovThe
393c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
3948b7475edSRuslan Ermilovfunction
39528fb27baSJustin T. Gibbstakes care of allocating and reallocating the match list as necessary.
39628fb27baSJustin T. GibbsCurrently known match types include:
3978b7475edSRuslan Ermilov.Bl -tag -width indent
39828fb27baSJustin T. Gibbs.It device type:
3998b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
4008b7475edSRuslan Ermilov.It Li da
40128fb27baSJustin T. GibbsDirect Access devices
4028b7475edSRuslan Ermilov.It Li sa
40328fb27baSJustin T. GibbsSequential Access devices
4048b7475edSRuslan Ermilov.It Li printer
40528fb27baSJustin T. GibbsPrinters
4068b7475edSRuslan Ermilov.It Li proc
40728fb27baSJustin T. GibbsProcessor devices
4088b7475edSRuslan Ermilov.It Li worm
40928fb27baSJustin T. GibbsWrite Once Read Multiple devices
4108b7475edSRuslan Ermilov.It Li cd
41128fb27baSJustin T. GibbsCD devices
4128b7475edSRuslan Ermilov.It Li scanner
41328fb27baSJustin T. GibbsScanner devices
4148b7475edSRuslan Ermilov.It Li optical
41528fb27baSJustin T. GibbsOptical Memory devices
4168b7475edSRuslan Ermilov.It Li changer
41728fb27baSJustin T. GibbsMedium Changer devices
4188b7475edSRuslan Ermilov.It Li comm
41928fb27baSJustin T. GibbsCommunication devices
4208b7475edSRuslan Ermilov.It Li array
42128fb27baSJustin T. GibbsStorage Array devices
4228b7475edSRuslan Ermilov.It Li enclosure
42328fb27baSJustin T. GibbsEnclosure Services devices
4248b7475edSRuslan Ermilov.It Li floppy
42528fb27baSJustin T. GibbsFloppy devices
42628fb27baSJustin T. Gibbs.El
42728fb27baSJustin T. Gibbs.It interface:
4288b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
4298b7475edSRuslan Ermilov.It Li IDE
43028fb27baSJustin T. GibbsIntegrated Drive Electronics devices
4318b7475edSRuslan Ermilov.It Li SCSI
43228fb27baSJustin T. GibbsSmall Computer System Interface devices
4338b7475edSRuslan Ermilov.It Li other
43428fb27baSJustin T. GibbsAny other device interface
43528fb27baSJustin T. Gibbs.El
43628fb27baSJustin T. Gibbs.It passthrough:
4378b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
4388b7475edSRuslan Ermilov.It Li pass
43928fb27baSJustin T. GibbsPassthrough devices
44028fb27baSJustin T. Gibbs.El
44128fb27baSJustin T. Gibbs.El
44228fb27baSJustin T. Gibbs.Pp
4438b7475edSRuslan ErmilovThe
444c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
4454a12d2d1SKenneth D. Merryfunction provides complete statistics calculation.
4468b7475edSRuslan ErmilovThere are four arguments for which values
4478b7475edSRuslan Ermilov.Em must
4488b7475edSRuslan Ermilovbe supplied:
4498b7475edSRuslan Ermilov.Fa current ,
4508b7475edSRuslan Ermilov.Fa previous ,
4518b7475edSRuslan Ermilov.Fa etime ,
452c4a5ef6eSThomas Moestland the terminating argument for the varargs list,
4538b7475edSRuslan Ermilov.Dv DSM_NONE .
4548b7475edSRuslan ErmilovFor most applications, the user will want to supply valid
4558b7475edSRuslan Ermilov.Vt devstat
456c4a5ef6eSThomas Moestlstructures for both
4578b7475edSRuslan Ermilov.Fa current
458c4a5ef6eSThomas Moestland
4598b7475edSRuslan Ermilov.Fa previous .
460c4a5ef6eSThomas MoestlIn some instances, for instance when calculating statistics since system
4618b7475edSRuslan Ermilovboot, the user may pass in a
4628b7475edSRuslan Ermilov.Dv NULL
4638b7475edSRuslan Ermilovpointer for the
4648b7475edSRuslan Ermilov.Fa previous
465c4a5ef6eSThomas Moestlargument.
466c4a5ef6eSThomas MoestlIn that case,
467c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
468c4a5ef6eSThomas Moestlwill use the total stats in the
4698b7475edSRuslan Ermilov.Fa current
470c4a5ef6eSThomas Moestlstructure to calculate statistics over
4718b7475edSRuslan Ermilov.Fa etime .
4728b7475edSRuslan ErmilovFor each statistics to be calculated, the user should supply the proper
473c4a5ef6eSThomas Moestlenumerated type (listed below), and a variable of the indicated type.
4748b7475edSRuslan ErmilovAll statistics are either integer values, for which a
4756b99842aSEd Schouten.Vt uint64_t
4768b7475edSRuslan Ermilovis used,
4778b7475edSRuslan Ermilovor floating point, for which a
4788b7475edSRuslan Ermilov.Vt "long double"
4798b7475edSRuslan Ermilovis used.
480c4a5ef6eSThomas MoestlThe statistics that may be calculated are:
4818b7475edSRuslan Ermilov.Bl -tag -width ".Dv DSM_TRANSFERS_PER_SECOND_OTHER"
4828b7475edSRuslan Ermilov.It Dv DSM_NONE
483c4a5ef6eSThomas Moestltype: N/A
484c4a5ef6eSThomas Moestl.Pp
4858b7475edSRuslan ErmilovThis
4868b7475edSRuslan Ermilov.Em must
487c4a5ef6eSThomas Moestlbe the last argument passed to
488c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics .
489c4a5ef6eSThomas MoestlIt is an argument list terminator.
4908b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES
4918b7475edSRuslan Ermilovtype:
4926b99842aSEd Schouten.Vt "uint64_t *"
493c4a5ef6eSThomas Moestl.Pp
494c4a5ef6eSThomas MoestlThe total number of bytes transferred between the acquisition of
4958b7475edSRuslan Ermilov.Fa previous
496c4a5ef6eSThomas Moestland
4978b7475edSRuslan Ermilov.Fa current .
4988b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_READ
4998b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_WRITE
5008b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_FREE
5018b7475edSRuslan Ermilovtype:
5026b99842aSEd Schouten.Vt "uint64_t *"
503c4a5ef6eSThomas Moestl.Pp
504b193011aSPoul-Henning KampThe total number of bytes in transactions of the specified type
505b193011aSPoul-Henning Kampbetween the acquisition of
5068b7475edSRuslan Ermilov.Fa previous
507c4a5ef6eSThomas Moestland
5088b7475edSRuslan Ermilov.Fa current .
5098b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS
5108b7475edSRuslan Ermilovtype:
5116b99842aSEd Schouten.Vt "uint64_t *"
512c4a5ef6eSThomas Moestl.Pp
513c4a5ef6eSThomas MoestlThe total number of transfers between the acquisition of
5148b7475edSRuslan Ermilov.Fa previous
515c4a5ef6eSThomas Moestland
5168b7475edSRuslan Ermilov.Fa current .
5178b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_OTHER
5188b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_READ
5198b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_WRITE
5208b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_FREE
5218b7475edSRuslan Ermilovtype:
5226b99842aSEd Schouten.Vt "uint64_t *"
523c4a5ef6eSThomas Moestl.Pp
524b193011aSPoul-Henning KampThe total number of transactions of the specified type between
525b193011aSPoul-Henning Kampthe acquisition of
5268b7475edSRuslan Ermilov.Fa previous
527c4a5ef6eSThomas Moestland
5288b7475edSRuslan Ermilov.Fa current .
529*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION
530*fdd6757eSMikolaj Golubtype:
531*fdd6757eSMikolaj Golub.Vt "long double *"
532*fdd6757eSMikolaj Golub.Pp
533*fdd6757eSMikolaj GolubThe total duration of transactions, in seconds, between the acquisition of
534*fdd6757eSMikolaj Golub.Fa previous
535*fdd6757eSMikolaj Goluband
536*fdd6757eSMikolaj Golub.Fa current .
537*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_OTHER
538*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_READ
539*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_WRITE
540*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_FREE
541*fdd6757eSMikolaj Golubtype:
542*fdd6757eSMikolaj Golub.Vt "long double *"
543*fdd6757eSMikolaj Golub.Pp
544*fdd6757eSMikolaj GolubThe total duration of transactions of the specified type between
545*fdd6757eSMikolaj Golubthe acquisition of
546*fdd6757eSMikolaj Golub.Fa previous
547*fdd6757eSMikolaj Goluband
548*fdd6757eSMikolaj Golub.Fa current .
549*fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_BUSY_TIME
550*fdd6757eSMikolaj Golubtype:
551*fdd6757eSMikolaj Golub.Vt "long double *"
552*fdd6757eSMikolaj Golub.Pp
553*fdd6757eSMikolaj GolubTotal time the device had one or more transactions outstanding
554*fdd6757eSMikolaj Golubbetween the acquisition of
555*fdd6757eSMikolaj Golub.Fa previous
556*fdd6757eSMikolaj Goluband
557*fdd6757eSMikolaj Golub.Fa current .
5588b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS
5598b7475edSRuslan Ermilovtype:
5606b99842aSEd Schouten.Vt "uint64_t *"
561c4a5ef6eSThomas Moestl.Pp
562c4a5ef6eSThomas MoestlThe total number of blocks transferred between the acquisition of
5638b7475edSRuslan Ermilov.Fa previous
564c4a5ef6eSThomas Moestland
5658b7475edSRuslan Ermilov.Fa current .
566c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
5671a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
568c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
5698b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_READ
5708b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_WRITE
5718b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_FREE
5728b7475edSRuslan Ermilovtype:
5736b99842aSEd Schouten.Vt "uint64_t *"
574c4a5ef6eSThomas Moestl.Pp
575b193011aSPoul-Henning KampThe total number of blocks of the specified type between the acquisition of
5768b7475edSRuslan Ermilov.Fa previous
577c4a5ef6eSThomas Moestland
5788b7475edSRuslan Ermilov.Fa current .
579c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
5801a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
581c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
5828b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER
5838b7475edSRuslan Ermilovtype:
5848b7475edSRuslan Ermilov.Vt "long double *"
585c4a5ef6eSThomas Moestl.Pp
586c4a5ef6eSThomas MoestlThe average number of kilobytes per transfer between the acquisition of
5878b7475edSRuslan Ermilov.Fa previous
588c4a5ef6eSThomas Moestland
5898b7475edSRuslan Ermilov.Fa current .
5908b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_READ
5918b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_WRITE
5928b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_FREE
5938b7475edSRuslan Ermilovtype:
5948b7475edSRuslan Ermilov.Vt "long double *"
595c4a5ef6eSThomas Moestl.Pp
596b193011aSPoul-Henning KampThe average number of kilobytes in the specified type transaction between
597b193011aSPoul-Henning Kampthe acquisition of
5988b7475edSRuslan Ermilov.Fa previous
599c4a5ef6eSThomas Moestland
6008b7475edSRuslan Ermilov.Fa current .
6018b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND
6028b7475edSRuslan Ermilovtype:
6038b7475edSRuslan Ermilov.Vt "long double *"
604c4a5ef6eSThomas Moestl.Pp
605c4a5ef6eSThomas MoestlThe average number of transfers per second between the acquisition of
6068b7475edSRuslan Ermilov.Fa previous
607c4a5ef6eSThomas Moestland
6088b7475edSRuslan Ermilov.Fa current .
6098b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_OTHER
6108b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_READ
6118b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_WRITE
6128b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_FREE
6138b7475edSRuslan Ermilovtype:
6148b7475edSRuslan Ermilov.Vt "long double *"
615c4a5ef6eSThomas Moestl.Pp
616b193011aSPoul-Henning KampThe average number of transactions of the specified type per second
617b193011aSPoul-Henning Kampbetween the acquisition of
6188b7475edSRuslan Ermilov.Fa previous
619c4a5ef6eSThomas Moestland
6208b7475edSRuslan Ermilov.Fa current .
6218b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND
6228b7475edSRuslan Ermilovtype:
6238b7475edSRuslan Ermilov.Vt "long double *"
624c4a5ef6eSThomas Moestl.Pp
625c4a5ef6eSThomas MoestlThe average number of megabytes transferred per second between the
626c4a5ef6eSThomas Moestlacquisition of
6278b7475edSRuslan Ermilov.Fa previous
628c4a5ef6eSThomas Moestland
6298b7475edSRuslan Ermilov.Fa current .
6308b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_READ
6318b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_WRITE
6328b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_FREE
6338b7475edSRuslan Ermilovtype:
6348b7475edSRuslan Ermilov.Vt "long double *"
635c4a5ef6eSThomas Moestl.Pp
636b193011aSPoul-Henning KampThe average number of megabytes per second in the specified type of
637b193011aSPoul-Henning Kamptransaction between the acquisition of
6388b7475edSRuslan Ermilov.Fa previous
639c4a5ef6eSThomas Moestland
6408b7475edSRuslan Ermilov.Fa current .
6418b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND
6428b7475edSRuslan Ermilovtype:
6438b7475edSRuslan Ermilov.Vt "long double *"
644c4a5ef6eSThomas Moestl.Pp
645c4a5ef6eSThomas MoestlThe average number of blocks transferred per second between the acquisition of
6468b7475edSRuslan Ermilov.Fa previous
647c4a5ef6eSThomas Moestland
6488b7475edSRuslan Ermilov.Fa current .
649c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
6501a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
651c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
6528b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_READ
6538b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_WRITE
6548b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_FREE
6558b7475edSRuslan Ermilovtype:
6568b7475edSRuslan Ermilov.Vt "long double *"
657c4a5ef6eSThomas Moestl.Pp
658799162a6SJoel DahlThe average number of blocks per second in the specified type of transaction
659b193011aSPoul-Henning Kampbetween the acquisition of
6608b7475edSRuslan Ermilov.Fa previous
661c4a5ef6eSThomas Moestland
6628b7475edSRuslan Ermilov.Fa current .
663c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
6641a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
665c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
6668b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION
6678b7475edSRuslan Ermilovtype:
6688b7475edSRuslan Ermilov.Vt "long double *"
669c4a5ef6eSThomas Moestl.Pp
670b193011aSPoul-Henning KampThe average duration of transactions between the acquisition of
6718b7475edSRuslan Ermilov.Fa previous
672c4a5ef6eSThomas Moestland
6738b7475edSRuslan Ermilov.Fa current .
6748b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_OTHER
6758b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_READ
6768b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_WRITE
6778b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_FREE
6788b7475edSRuslan Ermilovtype:
6798b7475edSRuslan Ermilov.Vt "long double *"
680c4a5ef6eSThomas Moestl.Pp
681b193011aSPoul-Henning KampThe average duration of transactions of the specified type between the
682b193011aSPoul-Henning Kampacquisition of
6838b7475edSRuslan Ermilov.Fa previous
684c4a5ef6eSThomas Moestland
6858b7475edSRuslan Ermilov.Fa current .
6868b7475edSRuslan Ermilov.It Dv DSM_BUSY_PCT
6878b7475edSRuslan Ermilovtype:
6888b7475edSRuslan Ermilov.Vt "long double *"
689b193011aSPoul-Henning Kamp.Pp
690b193011aSPoul-Henning KampThe percentage of time the device had one or more transactions outstanding
691b193011aSPoul-Henning Kampbetween the acquisition of
6928b7475edSRuslan Ermilov.Fa previous
693b193011aSPoul-Henning Kampand
6948b7475edSRuslan Ermilov.Fa current .
6958b7475edSRuslan Ermilov.It Dv DSM_QUEUE_LENGTH
6968b7475edSRuslan Ermilovtype:
6976b99842aSEd Schouten.Vt "uint64_t *"
698b193011aSPoul-Henning Kamp.Pp
699b193011aSPoul-Henning KampThe number of not yet completed transactions at the time when
7008b7475edSRuslan Ermilov.Fa current
701b193011aSPoul-Henning Kampwas acquired.
7028b7475edSRuslan Ermilov.It Dv DSM_SKIP
703884539f7SKenneth D. Merrytype: N/A
704884539f7SKenneth D. Merry.Pp
705884539f7SKenneth D. MerryIf you do not need a result from
706884539f7SKenneth D. Merry.Fn devstat_compute_statistics ,
707884539f7SKenneth D. Merryjust put
7088b7475edSRuslan Ermilov.Dv DSM_SKIP
709884539f7SKenneth D. Merryas first (type) parameter and
7108b7475edSRuslan Ermilov.Dv NULL
711884539f7SKenneth D. Merryas second parameter.
712884539f7SKenneth D. MerryThis can be useful in scenarios where the statistics to be calculated
713884539f7SKenneth D. Merryare determined at run time.
714c4a5ef6eSThomas Moestl.El
715c4a5ef6eSThomas Moestl.Pp
716634eb5fbSPhilippe CharnierThe
717c4a5ef6eSThomas Moestl.Fn devstat_compute_etime
718634eb5fbSPhilippe Charnierfunction
71928fb27baSJustin T. Gibbsprovides an easy way to find the difference in seconds between two
7208b7475edSRuslan Ermilov.Vt bintime
721c4a5ef6eSThomas Moestlstructures.
722c4a5ef6eSThomas MoestlThis is most commonly used in conjunction with the time recorded by the
723c4a5ef6eSThomas Moestl.Fn devstat_getdevs
7248b7475edSRuslan Ermilovfunction (in
7258b7475edSRuslan Ermilov.Vt "struct statinfo" )
72628fb27baSJustin T. Gibbseach time it fetches the current
72728fb27baSJustin T. Gibbs.Nm
72828fb27baSJustin T. Gibbslist.
72928fb27baSJustin T. Gibbs.Sh RETURN VALUES
7308b7475edSRuslan ErmilovThe
731c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs ,
732c4a5ef6eSThomas Moestl.Fn devstat_getgeneration ,
73328fb27baSJustin T. Gibbsand
734c4a5ef6eSThomas Moestl.Fn devstat_getversion
7358b7475edSRuslan Ermilovfunction
7368b7475edSRuslan Ermilovreturn the indicated sysctl variable, or \-1 if there is an error
73728fb27baSJustin T. Gibbsfetching the variable.
73828fb27baSJustin T. Gibbs.Pp
7398b7475edSRuslan ErmilovThe
740c4a5ef6eSThomas Moestl.Fn devstat_checkversion
7418b7475edSRuslan Ermilovfunction
74228fb27baSJustin T. Gibbsreturns 0 if the kernel and userland
7433b8ecdbbSRuslan Ermilov.Nm
744c4a5ef6eSThomas Moestlversions match.
7458b7475edSRuslan ErmilovIf they do not match, it returns \-1.
74628fb27baSJustin T. Gibbs.Pp
7478b7475edSRuslan ErmilovThe
748c4a5ef6eSThomas Moestl.Fn devstat_getdevs
74928fb27baSJustin T. Gibbsand
750c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
7518b7475edSRuslan Ermilovfunctions
7528b7475edSRuslan Ermilovreturn \-1 in case of an error, 0 if there is no error, and 1 if the device
753c4a5ef6eSThomas Moestllist or selected devices have changed.
754c4a5ef6eSThomas MoestlA return value of 1 from
755c4a5ef6eSThomas Moestl.Fn devstat_getdevs
75628fb27baSJustin T. Gibbsis usually a hint to re-run
757c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
75828fb27baSJustin T. Gibbsbecause the device list has changed.
75928fb27baSJustin T. Gibbs.Pp
7608b7475edSRuslan ErmilovThe
761c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
7628b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 if there is no error.
76328fb27baSJustin T. Gibbs.Pp
7648b7475edSRuslan ErmilovThe
765c4a5ef6eSThomas Moestl.Fn devstat_compute_etime
7668b7475edSRuslan Ermilovfunction
76728fb27baSJustin T. Gibbsreturns the computed elapsed time.
76828fb27baSJustin T. Gibbs.Pp
7698b7475edSRuslan ErmilovThe
770c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
7718b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 for success.
772c4a5ef6eSThomas Moestl.Pp
77328fb27baSJustin T. GibbsIf an error is returned from one of the
77428fb27baSJustin T. Gibbs.Nm
77528fb27baSJustin T. Gibbslibrary functions, the reason for the error is generally printed in
77628fb27baSJustin T. Gibbsthe global string
77728fb27baSJustin T. Gibbs.Va devstat_errbuf
77828fb27baSJustin T. Gibbswhich is
77928fb27baSJustin T. Gibbs.Dv DEVSTAT_ERRBUF_SIZE
78028fb27baSJustin T. Gibbscharacters long.
78128fb27baSJustin T. Gibbs.Sh SEE ALSO
78228fb27baSJustin T. Gibbs.Xr systat 1 ,
783c4a5ef6eSThomas Moestl.Xr kvm 3 ,
784c4a5ef6eSThomas Moestl.Xr sysctl 3 ,
78528fb27baSJustin T. Gibbs.Xr iostat 8 ,
78628fb27baSJustin T. Gibbs.Xr rpc.rstatd 8 ,
787265c01dfSRuslan Ermilov.Xr sysctl 8 ,
78828fb27baSJustin T. Gibbs.Xr vmstat 8 ,
78928fb27baSJustin T. Gibbs.Xr devstat 9
79028fb27baSJustin T. Gibbs.Sh HISTORY
79128fb27baSJustin T. GibbsThe
79228fb27baSJustin T. Gibbs.Nm
79328fb27baSJustin T. Gibbsstatistics system first appeared in
79428fb27baSJustin T. Gibbs.Fx 3.0 .
7958b7475edSRuslan ErmilovThe new interface (the functions prefixed with
7968b7475edSRuslan Ermilov.Li devstat_ )
7978b7475edSRuslan Ermilovfirst appeared in
798c4a5ef6eSThomas Moestl.Fx 5.0 .
79928fb27baSJustin T. Gibbs.Sh AUTHORS
800d0353b83SRuslan Ermilov.An Kenneth Merry Aq ken@FreeBSD.org
80128fb27baSJustin T. Gibbs.Sh BUGS
80228fb27baSJustin T. GibbsThere should probably be an interface to de-allocate memory allocated by
803c4a5ef6eSThomas Moestl.Fn devstat_getdevs ,
804c4a5ef6eSThomas Moestl.Fn devstat_selectdevs ,
80528fb27baSJustin T. Gibbsand
806c4a5ef6eSThomas Moestl.Fn devstat_buildmatch .
80728fb27baSJustin T. Gibbs.Pp
8088b7475edSRuslan ErmilovThe
809c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
8108b7475edSRuslan Ermilovfunction
81128fb27baSJustin T. Gibbsshould probably not select more than
8128b7475edSRuslan Ermilov.Fa maxshowdevs
81328fb27baSJustin T. Gibbsdevices in
81428fb27baSJustin T. Gibbs.Dq top
81528fb27baSJustin T. Gibbsmode when no devices have been selected previously.
81628fb27baSJustin T. Gibbs.Pp
81728fb27baSJustin T. GibbsThere should probably be functions to perform the statistics buffer
81828fb27baSJustin T. Gibbsswapping that goes on in most of the clients of this library.
81928fb27baSJustin T. Gibbs.Pp
82028fb27baSJustin T. GibbsThe
8218b7475edSRuslan Ermilov.Vt statinfo
82228fb27baSJustin T. Gibbsand
8238b7475edSRuslan Ermilov.Vt devinfo
82428fb27baSJustin T. Gibbsstructures should probably be cleaned up and thought out a little more.
825