xref: /freebsd-14.2/lib/libdevstat/devstat.3 (revision fa9896e0)
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.\"
28fdd6757eSMikolaj Golub.Dd December 15, 2012
2928fb27baSJustin T. Gibbs.Dt DEVSTAT 3
30a307d598SRuslan Ermilov.Os
3128fb27baSJustin T. Gibbs.Sh NAME
32b27e4ff3SAlexey Zelkin.Nm devstat ,
33c4a5ef6eSThomas Moestl.Nm devstat_getnumdevs ,
34c4a5ef6eSThomas Moestl.Nm devstat_getgeneration ,
35c4a5ef6eSThomas Moestl.Nm devstat_getversion ,
36c4a5ef6eSThomas Moestl.Nm devstat_checkversion ,
37c4a5ef6eSThomas Moestl.Nm devstat_getdevs ,
38c4a5ef6eSThomas Moestl.Nm devstat_selectdevs ,
39c4a5ef6eSThomas Moestl.Nm devstat_buildmatch ,
40c4a5ef6eSThomas Moestl.Nm devstat_compute_statistics ,
413a5146d9SRuslan Ermilov.Nm devstat_compute_etime
4228fb27baSJustin T. Gibbs.Nd device statistics utility library
439d5b4f83SAlexey Zelkin.Sh LIBRARY
449d5b4f83SAlexey Zelkin.Lb libdevstat
4528fb27baSJustin T. Gibbs.Sh SYNOPSIS
4632eef9aeSRuslan Ermilov.In devstat.h
4728fb27baSJustin T. Gibbs.Ft int
488b7475edSRuslan Ermilov.Fn devstat_getnumdevs "kvm_t *kd"
49c4a5ef6eSThomas Moestl.Ft long
508b7475edSRuslan Ermilov.Fn devstat_getgeneration "kvm_t *kd"
51c4a5ef6eSThomas Moestl.Ft int
528b7475edSRuslan Ermilov.Fn devstat_getversion "kvm_t *kd"
53c4a5ef6eSThomas Moestl.Ft int
548b7475edSRuslan Ermilov.Fn devstat_checkversion "kvm_t *kd"
55c4a5ef6eSThomas Moestl.Ft int
568b7475edSRuslan Ermilov.Fn devstat_getdevs "kvm_t *kd" "struct statinfo *stats"
57c4a5ef6eSThomas Moestl.Ft int
58c4a5ef6eSThomas Moestl.Fo devstat_selectdevs
59c4a5ef6eSThomas Moestl.Fa "struct device_selection **dev_select"
60c4a5ef6eSThomas Moestl.Fa "int *num_selected"
61c4a5ef6eSThomas Moestl.Fa "int *num_selections"
62c4a5ef6eSThomas Moestl.Fa "long *select_generation"
63c4a5ef6eSThomas Moestl.Fa "long current_generation"
64c4a5ef6eSThomas Moestl.Fa "struct devstat *devices"
65c4a5ef6eSThomas Moestl.Fa "int numdevs"
66c4a5ef6eSThomas Moestl.Fa "struct devstat_match *matches"
67c4a5ef6eSThomas Moestl.Fa "int num_matches"
68c4a5ef6eSThomas Moestl.Fa "char **dev_selections"
69c4a5ef6eSThomas Moestl.Fa "int num_dev_selections"
70c4a5ef6eSThomas Moestl.Fa "devstat_select_mode select_mode"
71c4a5ef6eSThomas Moestl.Fa "int maxshowdevs"
72c4a5ef6eSThomas Moestl.Fa "int perf_select"
73c4a5ef6eSThomas Moestl.Fc
74c4a5ef6eSThomas Moestl.Ft int
75c4a5ef6eSThomas Moestl.Fo devstat_buildmatch
76c4a5ef6eSThomas Moestl.Fa "char *match_str"
77c4a5ef6eSThomas Moestl.Fa "struct devstat_match **matches"
78c4a5ef6eSThomas Moestl.Fa "int *num_matches"
79c4a5ef6eSThomas Moestl.Fc
80c4a5ef6eSThomas Moestl.Ft int
81c4a5ef6eSThomas Moestl.Fo devstat_compute_statistics
82c4a5ef6eSThomas Moestl.Fa "struct devstat *current"
83c4a5ef6eSThomas Moestl.Fa "struct devstat *previous"
840f393d5cSBruce Evans.Fa "long double etime"
85c4a5ef6eSThomas Moestl.Fa "..."
86c4a5ef6eSThomas Moestl.Fc
878b7475edSRuslan Ermilov.Ft "long double"
88634eb5fbSPhilippe Charnier.Fo devstat_compute_etime
89634eb5fbSPhilippe Charnier.Fa "struct bintime *cur_time"
90634eb5fbSPhilippe Charnier.Fa "struct bintime *prev_time"
91634eb5fbSPhilippe Charnier.Fc
9228fb27baSJustin T. Gibbs.Sh DESCRIPTION
9328fb27baSJustin T. GibbsThe
9428fb27baSJustin T. Gibbs.Nm
9528fb27baSJustin T. Gibbslibrary is a library of helper functions for dealing with the kernel
9628fb27baSJustin T. Gibbs.Xr devstat 9
9728fb27baSJustin T. Gibbsinterface, which is accessible to users via
98c4a5ef6eSThomas Moestl.Xr sysctl 3
99c4a5ef6eSThomas Moestland
100c4a5ef6eSThomas Moestl.Xr kvm 3 .
101b9154997SKenneth D. MerryAll functions that take a
1028b7475edSRuslan Ermilov.Vt "kvm_t *"
103c4a5ef6eSThomas Moestlas first argument can be passed
104c4a5ef6eSThomas Moestl.Dv NULL
105c4a5ef6eSThomas Moestlinstead of a kvm handle as this argument,
106c4a5ef6eSThomas Moestlwhich causes the data to be read via
10728fb27baSJustin T. Gibbs.Xr sysctl 3 .
108c4a5ef6eSThomas MoestlOtherwise, it is read via
109c4a5ef6eSThomas Moestl.Xr kvm 3
110c4a5ef6eSThomas Moestlusing the supplied handle.
1118b7475edSRuslan ErmilovThe
112c4a5ef6eSThomas Moestl.Fn devstat_checkversion
1138b7475edSRuslan Ermilovfunction
114c4a5ef6eSThomas Moestlshould be called with each kvm handle that is going to be used (or with
115c4a5ef6eSThomas Moestl.Dv NULL
116c4a5ef6eSThomas Moestlif
117c4a5ef6eSThomas Moestl.Xr sysctl 3
118c4a5ef6eSThomas Moestlis going to be used).
11928fb27baSJustin T. Gibbs.Pp
1208b7475edSRuslan ErmilovThe
121c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs
1228b7475edSRuslan Ermilovfunction
12328fb27baSJustin T. Gibbsreturns the number of devices registered with the
1243b8ecdbbSRuslan Ermilov.Nm
12528fb27baSJustin T. Gibbssubsystem in the kernel.
12628fb27baSJustin T. Gibbs.Pp
1278b7475edSRuslan ErmilovThe
128c4a5ef6eSThomas Moestl.Fn devstat_getgeneration
1298b7475edSRuslan Ermilovfunction
13028fb27baSJustin T. Gibbsreturns the current generation of the
1313b8ecdbbSRuslan Ermilov.Nm
13228fb27baSJustin T. Gibbslist of devices in the kernel.
13328fb27baSJustin T. Gibbs.Pp
1348b7475edSRuslan ErmilovThe
135c4a5ef6eSThomas Moestl.Fn devstat_getversion
1368b7475edSRuslan Ermilovfunction
13728fb27baSJustin T. Gibbsreturns the current kernel
1383b8ecdbbSRuslan Ermilov.Nm
13928fb27baSJustin T. Gibbsversion.
14028fb27baSJustin T. Gibbs.Pp
1418b7475edSRuslan ErmilovThe
142c4a5ef6eSThomas Moestl.Fn devstat_checkversion
1438b7475edSRuslan Ermilovfunction
1448b7475edSRuslan Ermilovchecks the userland
1458b7475edSRuslan Ermilov.Nm
1468b7475edSRuslan Ermilovversion against the kernel
1478b7475edSRuslan Ermilov.Nm
1488b7475edSRuslan Ermilovversion.
149c4a5ef6eSThomas MoestlIf the two are identical, it returns zero.
150c4a5ef6eSThomas MoestlOtherwise, it prints an appropriate error in
15128fb27baSJustin T. Gibbs.Va devstat_errbuf
1528b7475edSRuslan Ermilovand returns \-1.
15328fb27baSJustin T. Gibbs.Pp
1548b7475edSRuslan ErmilovThe
155c4a5ef6eSThomas Moestl.Fn devstat_getdevs
1568b7475edSRuslan Ermilovfunction
15728fb27baSJustin T. Gibbsfetches the current list of devices and statistics into the supplied
1588b7475edSRuslan Ermilov.Vt statinfo
159c4a5ef6eSThomas Moestlstructure.
160c4a5ef6eSThomas MoestlThe
1618b7475edSRuslan Ermilov.Vt statinfo
16228fb27baSJustin T. Gibbsstructure can be found in
163fe08efe6SRuslan Ermilov.In devstat.h :
16428fb27baSJustin T. Gibbs.Bd -literal -offset indent
16528fb27baSJustin T. Gibbsstruct statinfo {
16628fb27baSJustin T. Gibbs	long            cp_time[CPUSTATES];
16728fb27baSJustin T. Gibbs	long            tk_nin;
16828fb27baSJustin T. Gibbs	long            tk_nout;
16928fb27baSJustin T. Gibbs	struct devinfo  *dinfo;
170b193011aSPoul-Henning Kamp	long double     snap_time;
17128fb27baSJustin T. Gibbs};
17228fb27baSJustin T. Gibbs.Ed
17328fb27baSJustin T. Gibbs.Pp
1748b7475edSRuslan ErmilovThe
175c4a5ef6eSThomas Moestl.Fn devstat_getdevs
1768b7475edSRuslan Ermilovfunction
17728fb27baSJustin T. Gibbsexpects the
1788b7475edSRuslan Ermilov.Vt statinfo
17928fb27baSJustin T. Gibbsstructure to be allocated, and it also expects the
18028fb27baSJustin T. Gibbs.Va dinfo
1816f83979dSKenneth D. Merrysubelement to be allocated and zeroed prior to the first invocation of
182c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
1836f83979dSKenneth D. MerryThe
1846f83979dSKenneth D. Merry.Va dinfo
1856f83979dSKenneth D. Merrysubelement is used to store state between calls, and should not be modified
1866f83979dSKenneth D. Merryafter the first call to
187c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
1886f83979dSKenneth D. MerryThe
18928fb27baSJustin T. Gibbs.Va dinfo
19028fb27baSJustin T. Gibbssubelement contains the following elements:
19128fb27baSJustin T. Gibbs.Bd -literal -offset indent
19228fb27baSJustin T. Gibbsstruct devinfo {
19328fb27baSJustin T. Gibbs	struct devstat	*devices;
1946b99842aSEd Schouten	uint8_t		*mem_ptr;
195bcc6a3daSKenneth D. Merry	long		generation;
19628fb27baSJustin T. Gibbs	int		numdevs;
19728fb27baSJustin T. Gibbs};
19828fb27baSJustin T. Gibbs.Ed
19928fb27baSJustin T. Gibbs.Pp
20028fb27baSJustin T. GibbsThe
20128fb27baSJustin T. Gibbs.Va kern.devstat.all
2028b7475edSRuslan Ermilov.Xr sysctl 8
20328fb27baSJustin T. Gibbsvariable contains an array of
2043b8ecdbbSRuslan Ermilov.Nm
20528fb27baSJustin T. Gibbsstructures, but at the head of the array is the current
2063b8ecdbbSRuslan Ermilov.Nm
207c4a5ef6eSThomas Moestlgeneration.
208c4a5ef6eSThomas MoestlThe reason the generation is at the head of the buffer is so that userland
2098b7475edSRuslan Ermilovsoftware accessing the
2108b7475edSRuslan Ermilov.Nm
2118b7475edSRuslan Ermilovstatistics information can atomically get
212c4a5ef6eSThomas Moestlboth the statistics information and the corresponding generation number.
213c4a5ef6eSThomas MoestlIf client software were forced to get the generation number via a separate
2148b7475edSRuslan Ermilov.Xr sysctl 8
21528fb27baSJustin T. Gibbsvariable (which is available for convenience), the list of devices could
21628fb27baSJustin T. Gibbschange between the time the client gets the generation and the time the
21728fb27baSJustin T. Gibbsclient gets the device list.
21828fb27baSJustin T. Gibbs.Pp
21928fb27baSJustin T. GibbsThe
22028fb27baSJustin T. Gibbs.Va mem_ptr
22128fb27baSJustin T. Gibbssubelement of the
2228b7475edSRuslan Ermilov.Vt devinfo
22328fb27baSJustin T. Gibbsstructure is a pointer to memory that is allocated, and resized if
22428fb27baSJustin T. Gibbsnecessary, by
225c4a5ef6eSThomas Moestl.Fn devstat_getdevs .
22628fb27baSJustin T. GibbsThe devices subelement of the
2278b7475edSRuslan Ermilov.Vt devinfo
22828fb27baSJustin T. Gibbsstructure is basically a pointer to the beginning of the array of devstat
22928fb27baSJustin T. Gibbsstructures from the
23028fb27baSJustin T. Gibbs.Va kern.devstat.all
2318b7475edSRuslan Ermilov.Xr sysctl 8
232c4a5ef6eSThomas Moestlvariable (or the corresponding values read via
233c4a5ef6eSThomas Moestl.Xr kvm 3 ) .
234c4a5ef6eSThomas MoestlThe generation subelement of the
2358b7475edSRuslan Ermilov.Vt devinfo
236c4a5ef6eSThomas Moestlstructure contains the corresponding generation number.
23728fb27baSJustin T. GibbsThe
23828fb27baSJustin T. Gibbs.Va numdevs
23928fb27baSJustin T. Gibbssubelement of the
2408b7475edSRuslan Ermilov.Vt devinfo
24128fb27baSJustin T. Gibbsstructure contains the current
24228fb27baSJustin T. Gibbsnumber of devices registered with the kernel
2433b8ecdbbSRuslan Ermilov.Nm
24428fb27baSJustin T. Gibbssubsystem.
24528fb27baSJustin T. Gibbs.Pp
2468b7475edSRuslan ErmilovThe
247c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
2488b7475edSRuslan Ermilovfunction
24928fb27baSJustin T. Gibbsselects devices to display based upon a number of criteria:
2508b7475edSRuslan Ermilov.Bl -tag -width indent
25128fb27baSJustin T. Gibbs.It specified devices
252c4a5ef6eSThomas MoestlSpecified devices are the first selection priority.
2538b7475edSRuslan ErmilovThese are generally devices specified by name by the user e.g.\&
2548b7475edSRuslan Ermilov.Li da0 , da1 , cd0 .
25528fb27baSJustin T. Gibbs.It match patterns
25628fb27baSJustin T. GibbsThese are pattern matching expressions generated by
257c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
25828fb27baSJustin T. Gibbsfrom user input.
25928fb27baSJustin T. Gibbs.It performance
26028fb27baSJustin T. GibbsIf performance mode is enabled, devices will be sorted based on the
26128fb27baSJustin T. Gibbs.Va bytes
26228fb27baSJustin T. Gibbsfield in the
2638b7475edSRuslan Ermilov.Vt device_selection
26428fb27baSJustin T. Gibbsstructure passed in to
265c4a5ef6eSThomas Moestl.Fn devstat_selectdevs .
26628fb27baSJustin T. GibbsThe
26728fb27baSJustin T. Gibbs.Va bytes
268c4a5ef6eSThomas Moestlvalue currently must be maintained by the user.
269c4a5ef6eSThomas MoestlIn the future, this may be done for him in a
27028fb27baSJustin T. Gibbs.Nm
27128fb27baSJustin T. Gibbslibrary routine.
27228fb27baSJustin T. GibbsIf no devices have been selected by name or by pattern, the performance
27328fb27baSJustin T. Gibbstracking code will select every device in the system, and sort them by
274c4a5ef6eSThomas Moestlperformance.
275c4a5ef6eSThomas MoestlIf devices have been selected by name or pattern, the performance tracking
276c4a5ef6eSThomas Moestlcode will honor those selections and will only sort among the selected
277c4a5ef6eSThomas Moestldevices.
27828fb27baSJustin T. Gibbs.It order in the devstat list
2798b7475edSRuslan ErmilovIf the selection mode is set to
2808b7475edSRuslan Ermilov.Dv DS_SELECT_ADD ,
2818b7475edSRuslan Ermilovand if there are still less
28228fb27baSJustin T. Gibbsthan
2838b7475edSRuslan Ermilov.Fa maxshowdevs
28428fb27baSJustin T. Gibbsdevices selected,
285c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
28628fb27baSJustin T. Gibbswill automatically select up to
2878b7475edSRuslan Ermilov.Fa maxshowdevs
28828fb27baSJustin T. Gibbsdevices.
28928fb27baSJustin T. Gibbs.El
29028fb27baSJustin T. Gibbs.Pp
2918b7475edSRuslan ErmilovThe
292c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
2938b7475edSRuslan Ermilovfunction
29428fb27baSJustin T. Gibbsperforms selections in four different modes:
2958b7475edSRuslan Ermilov.Bl -tag -width ".Dv DS_SELECT_ADDONLY"
2968b7475edSRuslan Ermilov.It Dv DS_SELECT_ADD
2978b7475edSRuslan ErmilovIn
2988b7475edSRuslan Ermilov.Dq add
2998b7475edSRuslan Ermilovmode,
300c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
30128fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern.
30228fb27baSJustin T. GibbsIt will also select more devices, in devstat list order, until the number
30328fb27baSJustin T. Gibbsof selected devices is equal to
3048b7475edSRuslan Ermilov.Fa maxshowdevs
30528fb27baSJustin T. Gibbsor until all devices are
30628fb27baSJustin T. Gibbsselected.
3078b7475edSRuslan Ermilov.It Dv DS_SELECT_ONLY
3088b7475edSRuslan ErmilovIn
3098b7475edSRuslan Ermilov.Dq only
3108b7475edSRuslan Ermilovmode,
311c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
31228fb27baSJustin T. Gibbswill clear all current selections, and will only select devices specified
31328fb27baSJustin T. Gibbsby name or by matching pattern.
3148b7475edSRuslan Ermilov.It Dv DS_SELECT_REMOVE
3158b7475edSRuslan ErmilovIn
3168b7475edSRuslan Ermilov.Dq remove
3178b7475edSRuslan Ermilovmode,
318c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
319c4a5ef6eSThomas Moestlwill remove devices specified by name or by matching pattern.
320c4a5ef6eSThomas MoestlIt will not select any additional devices.
3218b7475edSRuslan Ermilov.It Dv DS_SELECT_ADDONLY
3228b7475edSRuslan ErmilovIn
3238b7475edSRuslan Ermilov.Dq "add only"
3248b7475edSRuslan Ermilovmode,
325c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
32628fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern.
3278b7475edSRuslan ErmilovIn this respect it is identical to
3288b7475edSRuslan Ermilov.Dq add
3298b7475edSRuslan Ermilovmode.
330c4a5ef6eSThomas MoestlIt will not, however, select any devices other than those specified.
33128fb27baSJustin T. Gibbs.El
33228fb27baSJustin T. Gibbs.Pp
33328fb27baSJustin T. GibbsIn all selection modes,
334c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
33528fb27baSJustin T. Gibbswill not select any more than
3368b7475edSRuslan Ermilov.Fa maxshowdevs
337c4a5ef6eSThomas Moestldevices.
338c4a5ef6eSThomas MoestlOne exception to this is when you are in
33928fb27baSJustin T. Gibbs.Dq top
340c4a5ef6eSThomas Moestlmode and no devices have been selected.
341c4a5ef6eSThomas MoestlIn this case,
342c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
343c4a5ef6eSThomas Moestlwill select every device in the system.
344c4a5ef6eSThomas MoestlClient programs must pay attention to selection order when deciding whether
345c4a5ef6eSThomas Moestlto pay attention to a particular device.
346c4a5ef6eSThomas MoestlThis may be the wrong behavior, and probably requires additional thought.
34728fb27baSJustin T. Gibbs.Pp
3488b7475edSRuslan ErmilovThe
349c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
3508b7475edSRuslan Ermilovfunction
35128fb27baSJustin T. Gibbshandles allocation and resizing of the
3528b7475edSRuslan Ermilov.Fa dev_select
35328fb27baSJustin T. Gibbsstructure passed in
35428fb27baSJustin T. Gibbsby the client.
3558b7475edSRuslan ErmilovThe
356c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
3578b7475edSRuslan Ermilovfunction
35828fb27baSJustin T. Gibbsuses the
3598b7475edSRuslan Ermilov.Fa numdevs
36028fb27baSJustin T. Gibbsand
3618b7475edSRuslan Ermilov.Fa current_generation
36228fb27baSJustin T. Gibbsfields to track the
36328fb27baSJustin T. Gibbscurrent
36428fb27baSJustin T. Gibbs.Nm
365c4a5ef6eSThomas Moestlgeneration and number of devices.
366c4a5ef6eSThomas MoestlIf
3678b7475edSRuslan Ermilov.Fa num_selections
36828fb27baSJustin T. Gibbsis not the same
36928fb27baSJustin T. Gibbsas
3708b7475edSRuslan Ermilov.Fa numdevs
37128fb27baSJustin T. Gibbsor if
3728b7475edSRuslan Ermilov.Fa select_generation
37328fb27baSJustin T. Gibbsis not the same as
3748b7475edSRuslan Ermilov.Fa current_generation ,
375c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
37628fb27baSJustin T. Gibbswill resize the selection list as necessary, and re-initialize the
37728fb27baSJustin T. Gibbsselection array.
37828fb27baSJustin T. Gibbs.Pp
3798b7475edSRuslan ErmilovThe
380c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
3818b7475edSRuslan Ermilovfunction
3828b7475edSRuslan Ermilovtakes a comma separated match string and compiles it into a
3838b7475edSRuslan Ermilov.Vt devstat_match
3848b7475edSRuslan Ermilovstructure that is understood by
3858b7475edSRuslan Ermilov.Fn devstat_selectdevs .
38628fb27baSJustin T. GibbsMatch strings have the following format:
38728fb27baSJustin T. Gibbs.Pp
3888b7475edSRuslan Ermilov.D1 Ar device , Ns Ar type , Ns Ar if
38928fb27baSJustin T. Gibbs.Pp
3908b7475edSRuslan ErmilovThe
391c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
3928b7475edSRuslan Ermilovfunction
39328fb27baSJustin T. Gibbstakes care of allocating and reallocating the match list as necessary.
39428fb27baSJustin T. GibbsCurrently known match types include:
3958b7475edSRuslan Ermilov.Bl -tag -width indent
39628fb27baSJustin T. Gibbs.It device type:
3978b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
3988b7475edSRuslan Ermilov.It Li da
39928fb27baSJustin T. GibbsDirect Access devices
4008b7475edSRuslan Ermilov.It Li sa
40128fb27baSJustin T. GibbsSequential Access devices
4028b7475edSRuslan Ermilov.It Li printer
40328fb27baSJustin T. GibbsPrinters
4048b7475edSRuslan Ermilov.It Li proc
40528fb27baSJustin T. GibbsProcessor devices
4068b7475edSRuslan Ermilov.It Li worm
40728fb27baSJustin T. GibbsWrite Once Read Multiple devices
4088b7475edSRuslan Ermilov.It Li cd
40928fb27baSJustin T. GibbsCD devices
4108b7475edSRuslan Ermilov.It Li scanner
41128fb27baSJustin T. GibbsScanner devices
4128b7475edSRuslan Ermilov.It Li optical
41328fb27baSJustin T. GibbsOptical Memory devices
4148b7475edSRuslan Ermilov.It Li changer
41528fb27baSJustin T. GibbsMedium Changer devices
4168b7475edSRuslan Ermilov.It Li comm
41728fb27baSJustin T. GibbsCommunication devices
4188b7475edSRuslan Ermilov.It Li array
41928fb27baSJustin T. GibbsStorage Array devices
4208b7475edSRuslan Ermilov.It Li enclosure
42128fb27baSJustin T. GibbsEnclosure Services devices
4228b7475edSRuslan Ermilov.It Li floppy
42328fb27baSJustin T. GibbsFloppy devices
42428fb27baSJustin T. Gibbs.El
42528fb27baSJustin T. Gibbs.It interface:
4268b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
4278b7475edSRuslan Ermilov.It Li IDE
42828fb27baSJustin T. GibbsIntegrated Drive Electronics devices
4298b7475edSRuslan Ermilov.It Li SCSI
43028fb27baSJustin T. GibbsSmall Computer System Interface devices
4318b7475edSRuslan Ermilov.It Li other
43228fb27baSJustin T. GibbsAny other device interface
43328fb27baSJustin T. Gibbs.El
43428fb27baSJustin T. Gibbs.It passthrough:
4358b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact
4368b7475edSRuslan Ermilov.It Li pass
43728fb27baSJustin T. GibbsPassthrough devices
43828fb27baSJustin T. Gibbs.El
43928fb27baSJustin T. Gibbs.El
44028fb27baSJustin T. Gibbs.Pp
4418b7475edSRuslan ErmilovThe
442c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
4434a12d2d1SKenneth D. Merryfunction provides complete statistics calculation.
4448b7475edSRuslan ErmilovThere are four arguments for which values
4458b7475edSRuslan Ermilov.Em must
4468b7475edSRuslan Ermilovbe supplied:
4478b7475edSRuslan Ermilov.Fa current ,
4488b7475edSRuslan Ermilov.Fa previous ,
4498b7475edSRuslan Ermilov.Fa etime ,
450c4a5ef6eSThomas Moestland the terminating argument for the varargs list,
4518b7475edSRuslan Ermilov.Dv DSM_NONE .
4528b7475edSRuslan ErmilovFor most applications, the user will want to supply valid
4538b7475edSRuslan Ermilov.Vt devstat
454c4a5ef6eSThomas Moestlstructures for both
4558b7475edSRuslan Ermilov.Fa current
456c4a5ef6eSThomas Moestland
4578b7475edSRuslan Ermilov.Fa previous .
458c4a5ef6eSThomas MoestlIn some instances, for instance when calculating statistics since system
4598b7475edSRuslan Ermilovboot, the user may pass in a
4608b7475edSRuslan Ermilov.Dv NULL
4618b7475edSRuslan Ermilovpointer for the
4628b7475edSRuslan Ermilov.Fa previous
463c4a5ef6eSThomas Moestlargument.
464c4a5ef6eSThomas MoestlIn that case,
465c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
466c4a5ef6eSThomas Moestlwill use the total stats in the
4678b7475edSRuslan Ermilov.Fa current
468c4a5ef6eSThomas Moestlstructure to calculate statistics over
4698b7475edSRuslan Ermilov.Fa etime .
4708b7475edSRuslan ErmilovFor each statistics to be calculated, the user should supply the proper
471c4a5ef6eSThomas Moestlenumerated type (listed below), and a variable of the indicated type.
4728b7475edSRuslan ErmilovAll statistics are either integer values, for which a
4736b99842aSEd Schouten.Vt uint64_t
4748b7475edSRuslan Ermilovis used,
4758b7475edSRuslan Ermilovor floating point, for which a
4768b7475edSRuslan Ermilov.Vt "long double"
4778b7475edSRuslan Ermilovis used.
478c4a5ef6eSThomas MoestlThe statistics that may be calculated are:
4798b7475edSRuslan Ermilov.Bl -tag -width ".Dv DSM_TRANSFERS_PER_SECOND_OTHER"
4808b7475edSRuslan Ermilov.It Dv DSM_NONE
481c4a5ef6eSThomas Moestltype: N/A
482c4a5ef6eSThomas Moestl.Pp
4838b7475edSRuslan ErmilovThis
4848b7475edSRuslan Ermilov.Em must
485c4a5ef6eSThomas Moestlbe the last argument passed to
486c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics .
487c4a5ef6eSThomas MoestlIt is an argument list terminator.
4888b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES
4898b7475edSRuslan Ermilovtype:
4906b99842aSEd Schouten.Vt "uint64_t *"
491c4a5ef6eSThomas Moestl.Pp
492c4a5ef6eSThomas MoestlThe total number of bytes transferred between the acquisition of
4938b7475edSRuslan Ermilov.Fa previous
494c4a5ef6eSThomas Moestland
4958b7475edSRuslan Ermilov.Fa current .
4968b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_READ
4978b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_WRITE
4988b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BYTES_FREE
4998b7475edSRuslan Ermilovtype:
5006b99842aSEd Schouten.Vt "uint64_t *"
501c4a5ef6eSThomas Moestl.Pp
502b193011aSPoul-Henning KampThe total number of bytes in transactions of the specified type
503b193011aSPoul-Henning Kampbetween the acquisition of
5048b7475edSRuslan Ermilov.Fa previous
505c4a5ef6eSThomas Moestland
5068b7475edSRuslan Ermilov.Fa current .
5078b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS
5088b7475edSRuslan Ermilovtype:
5096b99842aSEd Schouten.Vt "uint64_t *"
510c4a5ef6eSThomas Moestl.Pp
511c4a5ef6eSThomas MoestlThe total number of transfers between the acquisition of
5128b7475edSRuslan Ermilov.Fa previous
513c4a5ef6eSThomas Moestland
5148b7475edSRuslan Ermilov.Fa current .
5158b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_OTHER
5168b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_READ
5178b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_WRITE
5188b7475edSRuslan Ermilov.It Dv DSM_TOTAL_TRANSFERS_FREE
5198b7475edSRuslan Ermilovtype:
5206b99842aSEd Schouten.Vt "uint64_t *"
521c4a5ef6eSThomas Moestl.Pp
522b193011aSPoul-Henning KampThe total number of transactions of the specified type between
523b193011aSPoul-Henning Kampthe acquisition of
5248b7475edSRuslan Ermilov.Fa previous
525c4a5ef6eSThomas Moestland
5268b7475edSRuslan Ermilov.Fa current .
527fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION
528fdd6757eSMikolaj Golubtype:
529fdd6757eSMikolaj Golub.Vt "long double *"
530fdd6757eSMikolaj Golub.Pp
531fdd6757eSMikolaj GolubThe total duration of transactions, in seconds, between the acquisition of
532fdd6757eSMikolaj Golub.Fa previous
533fdd6757eSMikolaj Goluband
534fdd6757eSMikolaj Golub.Fa current .
535fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_OTHER
536fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_READ
537fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_WRITE
538fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_FREE
539fdd6757eSMikolaj Golubtype:
540fdd6757eSMikolaj Golub.Vt "long double *"
541fdd6757eSMikolaj Golub.Pp
542fdd6757eSMikolaj GolubThe total duration of transactions of the specified type between
543fdd6757eSMikolaj Golubthe acquisition of
544fdd6757eSMikolaj Golub.Fa previous
545fdd6757eSMikolaj Goluband
546fdd6757eSMikolaj Golub.Fa current .
547fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_BUSY_TIME
548fdd6757eSMikolaj Golubtype:
549fdd6757eSMikolaj Golub.Vt "long double *"
550fdd6757eSMikolaj Golub.Pp
551fdd6757eSMikolaj GolubTotal time the device had one or more transactions outstanding
552fdd6757eSMikolaj Golubbetween the acquisition of
553fdd6757eSMikolaj Golub.Fa previous
554fdd6757eSMikolaj Goluband
555fdd6757eSMikolaj Golub.Fa current .
5568b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS
5578b7475edSRuslan Ermilovtype:
5586b99842aSEd Schouten.Vt "uint64_t *"
559c4a5ef6eSThomas Moestl.Pp
560c4a5ef6eSThomas MoestlThe total number of blocks transferred between the acquisition of
5618b7475edSRuslan Ermilov.Fa previous
562c4a5ef6eSThomas Moestland
5638b7475edSRuslan Ermilov.Fa current .
564c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
5651a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
566c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
5678b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_READ
5688b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_WRITE
5698b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_FREE
5708b7475edSRuslan Ermilovtype:
5716b99842aSEd Schouten.Vt "uint64_t *"
572c4a5ef6eSThomas Moestl.Pp
573b193011aSPoul-Henning KampThe total number of blocks of the specified type between the acquisition of
5748b7475edSRuslan Ermilov.Fa previous
575c4a5ef6eSThomas Moestland
5768b7475edSRuslan Ermilov.Fa current .
577c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
5781a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
579c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
5808b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER
5818b7475edSRuslan Ermilovtype:
5828b7475edSRuslan Ermilov.Vt "long double *"
583c4a5ef6eSThomas Moestl.Pp
584c4a5ef6eSThomas MoestlThe average number of kilobytes per transfer between the acquisition of
5858b7475edSRuslan Ermilov.Fa previous
586c4a5ef6eSThomas Moestland
5878b7475edSRuslan Ermilov.Fa current .
5888b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_READ
5898b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_WRITE
5908b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_FREE
5918b7475edSRuslan Ermilovtype:
5928b7475edSRuslan Ermilov.Vt "long double *"
593c4a5ef6eSThomas Moestl.Pp
594b193011aSPoul-Henning KampThe average number of kilobytes in the specified type transaction between
595b193011aSPoul-Henning Kampthe acquisition of
5968b7475edSRuslan Ermilov.Fa previous
597c4a5ef6eSThomas Moestland
5988b7475edSRuslan Ermilov.Fa current .
5998b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND
6008b7475edSRuslan Ermilovtype:
6018b7475edSRuslan Ermilov.Vt "long double *"
602c4a5ef6eSThomas Moestl.Pp
603c4a5ef6eSThomas MoestlThe average number of transfers per second between the acquisition of
6048b7475edSRuslan Ermilov.Fa previous
605c4a5ef6eSThomas Moestland
6068b7475edSRuslan Ermilov.Fa current .
6078b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_OTHER
6088b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_READ
6098b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_WRITE
6108b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_FREE
6118b7475edSRuslan Ermilovtype:
6128b7475edSRuslan Ermilov.Vt "long double *"
613c4a5ef6eSThomas Moestl.Pp
614b193011aSPoul-Henning KampThe average number of transactions of the specified type per second
615b193011aSPoul-Henning Kampbetween the acquisition of
6168b7475edSRuslan Ermilov.Fa previous
617c4a5ef6eSThomas Moestland
6188b7475edSRuslan Ermilov.Fa current .
6198b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND
6208b7475edSRuslan Ermilovtype:
6218b7475edSRuslan Ermilov.Vt "long double *"
622c4a5ef6eSThomas Moestl.Pp
623c4a5ef6eSThomas MoestlThe average number of megabytes transferred per second between the
624c4a5ef6eSThomas Moestlacquisition of
6258b7475edSRuslan Ermilov.Fa previous
626c4a5ef6eSThomas Moestland
6278b7475edSRuslan Ermilov.Fa current .
6288b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_READ
6298b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_WRITE
6308b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_FREE
6318b7475edSRuslan Ermilovtype:
6328b7475edSRuslan Ermilov.Vt "long double *"
633c4a5ef6eSThomas Moestl.Pp
634b193011aSPoul-Henning KampThe average number of megabytes per second in the specified type of
635b193011aSPoul-Henning Kamptransaction between the acquisition of
6368b7475edSRuslan Ermilov.Fa previous
637c4a5ef6eSThomas Moestland
6388b7475edSRuslan Ermilov.Fa current .
6398b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND
6408b7475edSRuslan Ermilovtype:
6418b7475edSRuslan Ermilov.Vt "long double *"
642c4a5ef6eSThomas Moestl.Pp
643c4a5ef6eSThomas MoestlThe average number of blocks transferred per second between the acquisition of
6448b7475edSRuslan Ermilov.Fa previous
645c4a5ef6eSThomas Moestland
6468b7475edSRuslan Ermilov.Fa current .
647c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
6481a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
649c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
6508b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_READ
6518b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_WRITE
6528b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_FREE
6538b7475edSRuslan Ermilovtype:
6548b7475edSRuslan Ermilov.Vt "long double *"
655c4a5ef6eSThomas Moestl.Pp
656799162a6SJoel DahlThe average number of blocks per second in the specified type of transaction
657b193011aSPoul-Henning Kampbetween the acquisition of
6588b7475edSRuslan Ermilov.Fa previous
659c4a5ef6eSThomas Moestland
6608b7475edSRuslan Ermilov.Fa current .
661c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device.
6621a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default
663c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation.
6648b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION
6658b7475edSRuslan Ermilovtype:
6668b7475edSRuslan Ermilov.Vt "long double *"
667c4a5ef6eSThomas Moestl.Pp
668b193011aSPoul-Henning KampThe average duration of transactions between the acquisition of
6698b7475edSRuslan Ermilov.Fa previous
670c4a5ef6eSThomas Moestland
6718b7475edSRuslan Ermilov.Fa current .
6728b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_OTHER
6738b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_READ
6748b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_WRITE
6758b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_FREE
6768b7475edSRuslan Ermilovtype:
6778b7475edSRuslan Ermilov.Vt "long double *"
678c4a5ef6eSThomas Moestl.Pp
679b193011aSPoul-Henning KampThe average duration of transactions of the specified type between the
680b193011aSPoul-Henning Kampacquisition of
6818b7475edSRuslan Ermilov.Fa previous
682c4a5ef6eSThomas Moestland
6838b7475edSRuslan Ermilov.Fa current .
6848b7475edSRuslan Ermilov.It Dv DSM_BUSY_PCT
6858b7475edSRuslan Ermilovtype:
6868b7475edSRuslan Ermilov.Vt "long double *"
687b193011aSPoul-Henning Kamp.Pp
688b193011aSPoul-Henning KampThe percentage of time the device had one or more transactions outstanding
689b193011aSPoul-Henning Kampbetween the acquisition of
6908b7475edSRuslan Ermilov.Fa previous
691b193011aSPoul-Henning Kampand
6928b7475edSRuslan Ermilov.Fa current .
6938b7475edSRuslan Ermilov.It Dv DSM_QUEUE_LENGTH
6948b7475edSRuslan Ermilovtype:
6956b99842aSEd Schouten.Vt "uint64_t *"
696b193011aSPoul-Henning Kamp.Pp
697b193011aSPoul-Henning KampThe number of not yet completed transactions at the time when
6988b7475edSRuslan Ermilov.Fa current
699b193011aSPoul-Henning Kampwas acquired.
7008b7475edSRuslan Ermilov.It Dv DSM_SKIP
701884539f7SKenneth D. Merrytype: N/A
702884539f7SKenneth D. Merry.Pp
703884539f7SKenneth D. MerryIf you do not need a result from
704884539f7SKenneth D. Merry.Fn devstat_compute_statistics ,
705884539f7SKenneth D. Merryjust put
7068b7475edSRuslan Ermilov.Dv DSM_SKIP
707884539f7SKenneth D. Merryas first (type) parameter and
7088b7475edSRuslan Ermilov.Dv NULL
709884539f7SKenneth D. Merryas second parameter.
710884539f7SKenneth D. MerryThis can be useful in scenarios where the statistics to be calculated
711884539f7SKenneth D. Merryare determined at run time.
712c4a5ef6eSThomas Moestl.El
713c4a5ef6eSThomas Moestl.Pp
714634eb5fbSPhilippe CharnierThe
715c4a5ef6eSThomas Moestl.Fn devstat_compute_etime
716634eb5fbSPhilippe Charnierfunction
71728fb27baSJustin T. Gibbsprovides an easy way to find the difference in seconds between two
7188b7475edSRuslan Ermilov.Vt bintime
719c4a5ef6eSThomas Moestlstructures.
720c4a5ef6eSThomas MoestlThis is most commonly used in conjunction with the time recorded by the
721c4a5ef6eSThomas Moestl.Fn devstat_getdevs
7228b7475edSRuslan Ermilovfunction (in
7238b7475edSRuslan Ermilov.Vt "struct statinfo" )
72428fb27baSJustin T. Gibbseach time it fetches the current
72528fb27baSJustin T. Gibbs.Nm
72628fb27baSJustin T. Gibbslist.
72728fb27baSJustin T. Gibbs.Sh RETURN VALUES
7288b7475edSRuslan ErmilovThe
729c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs ,
730c4a5ef6eSThomas Moestl.Fn devstat_getgeneration ,
73128fb27baSJustin T. Gibbsand
732c4a5ef6eSThomas Moestl.Fn devstat_getversion
7338b7475edSRuslan Ermilovfunction
7348b7475edSRuslan Ermilovreturn the indicated sysctl variable, or \-1 if there is an error
73528fb27baSJustin T. Gibbsfetching the variable.
73628fb27baSJustin T. Gibbs.Pp
7378b7475edSRuslan ErmilovThe
738c4a5ef6eSThomas Moestl.Fn devstat_checkversion
7398b7475edSRuslan Ermilovfunction
74028fb27baSJustin T. Gibbsreturns 0 if the kernel and userland
7413b8ecdbbSRuslan Ermilov.Nm
742c4a5ef6eSThomas Moestlversions match.
7438b7475edSRuslan ErmilovIf they do not match, it returns \-1.
74428fb27baSJustin T. Gibbs.Pp
7458b7475edSRuslan ErmilovThe
746c4a5ef6eSThomas Moestl.Fn devstat_getdevs
74728fb27baSJustin T. Gibbsand
748c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
7498b7475edSRuslan Ermilovfunctions
7508b7475edSRuslan Ermilovreturn \-1 in case of an error, 0 if there is no error, and 1 if the device
751c4a5ef6eSThomas Moestllist or selected devices have changed.
752c4a5ef6eSThomas MoestlA return value of 1 from
753c4a5ef6eSThomas Moestl.Fn devstat_getdevs
75428fb27baSJustin T. Gibbsis usually a hint to re-run
755c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
75628fb27baSJustin T. Gibbsbecause the device list has changed.
75728fb27baSJustin T. Gibbs.Pp
7588b7475edSRuslan ErmilovThe
759c4a5ef6eSThomas Moestl.Fn devstat_buildmatch
7608b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 if there is no error.
76128fb27baSJustin T. Gibbs.Pp
7628b7475edSRuslan ErmilovThe
763c4a5ef6eSThomas Moestl.Fn devstat_compute_etime
7648b7475edSRuslan Ermilovfunction
76528fb27baSJustin T. Gibbsreturns the computed elapsed time.
76628fb27baSJustin T. Gibbs.Pp
7678b7475edSRuslan ErmilovThe
768c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics
7698b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 for success.
770c4a5ef6eSThomas Moestl.Pp
77128fb27baSJustin T. GibbsIf an error is returned from one of the
77228fb27baSJustin T. Gibbs.Nm
77328fb27baSJustin T. Gibbslibrary functions, the reason for the error is generally printed in
77428fb27baSJustin T. Gibbsthe global string
77528fb27baSJustin T. Gibbs.Va devstat_errbuf
77628fb27baSJustin T. Gibbswhich is
77728fb27baSJustin T. Gibbs.Dv DEVSTAT_ERRBUF_SIZE
77828fb27baSJustin T. Gibbscharacters long.
77928fb27baSJustin T. Gibbs.Sh SEE ALSO
78028fb27baSJustin T. Gibbs.Xr systat 1 ,
781c4a5ef6eSThomas Moestl.Xr kvm 3 ,
782c4a5ef6eSThomas Moestl.Xr sysctl 3 ,
78328fb27baSJustin T. Gibbs.Xr iostat 8 ,
78428fb27baSJustin T. Gibbs.Xr rpc.rstatd 8 ,
785265c01dfSRuslan Ermilov.Xr sysctl 8 ,
78628fb27baSJustin T. Gibbs.Xr vmstat 8 ,
78728fb27baSJustin T. Gibbs.Xr devstat 9
78828fb27baSJustin T. Gibbs.Sh HISTORY
78928fb27baSJustin T. GibbsThe
79028fb27baSJustin T. Gibbs.Nm
79128fb27baSJustin T. Gibbsstatistics system first appeared in
79228fb27baSJustin T. Gibbs.Fx 3.0 .
7938b7475edSRuslan ErmilovThe new interface (the functions prefixed with
7948b7475edSRuslan Ermilov.Li devstat_ )
7958b7475edSRuslan Ermilovfirst appeared in
796c4a5ef6eSThomas Moestl.Fx 5.0 .
79728fb27baSJustin T. Gibbs.Sh AUTHORS
798*2b7af31cSBaptiste Daroussin.An Kenneth Merry Aq Mt [email protected]
79928fb27baSJustin T. Gibbs.Sh BUGS
80028fb27baSJustin T. GibbsThere should probably be an interface to de-allocate memory allocated by
801c4a5ef6eSThomas Moestl.Fn devstat_getdevs ,
802c4a5ef6eSThomas Moestl.Fn devstat_selectdevs ,
80328fb27baSJustin T. Gibbsand
804c4a5ef6eSThomas Moestl.Fn devstat_buildmatch .
80528fb27baSJustin T. Gibbs.Pp
8068b7475edSRuslan ErmilovThe
807c4a5ef6eSThomas Moestl.Fn devstat_selectdevs
8088b7475edSRuslan Ermilovfunction
80928fb27baSJustin T. Gibbsshould probably not select more than
8108b7475edSRuslan Ermilov.Fa maxshowdevs
81128fb27baSJustin T. Gibbsdevices in
81228fb27baSJustin T. Gibbs.Dq top
81328fb27baSJustin T. Gibbsmode when no devices have been selected previously.
81428fb27baSJustin T. Gibbs.Pp
81528fb27baSJustin T. GibbsThere should probably be functions to perform the statistics buffer
81628fb27baSJustin T. Gibbsswapping that goes on in most of the clients of this library.
81728fb27baSJustin T. Gibbs.Pp
81828fb27baSJustin T. GibbsThe
8198b7475edSRuslan Ermilov.Vt statinfo
82028fb27baSJustin T. Gibbsand
8218b7475edSRuslan Ermilov.Vt devinfo
82228fb27baSJustin T. Gibbsstructures should probably be cleaned up and thought out a little more.
823