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.\" 308b7475edSRuslan Ermilov.Dd March 18, 2003 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" 908b7475edSRuslan Ermilov.Fn devstat_compute_etime "struct bintime cur_time" "struct bintime prev_time" 9128fb27baSJustin T. Gibbs.Sh DESCRIPTION 9228fb27baSJustin T. GibbsThe 9328fb27baSJustin T. Gibbs.Nm 9428fb27baSJustin T. Gibbslibrary is a library of helper functions for dealing with the kernel 9528fb27baSJustin T. Gibbs.Xr devstat 9 9628fb27baSJustin T. Gibbsinterface, which is accessible to users via 97c4a5ef6eSThomas Moestl.Xr sysctl 3 98c4a5ef6eSThomas Moestland 99c4a5ef6eSThomas Moestl.Xr kvm 3 . 100b9154997SKenneth D. MerryAll functions that take a 1018b7475edSRuslan Ermilov.Vt "kvm_t *" 102c4a5ef6eSThomas Moestlas first argument can be passed 103c4a5ef6eSThomas Moestl.Dv NULL 104c4a5ef6eSThomas Moestlinstead of a kvm handle as this argument, 105c4a5ef6eSThomas Moestlwhich causes the data to be read via 10628fb27baSJustin T. Gibbs.Xr sysctl 3 . 107c4a5ef6eSThomas MoestlOtherwise, it is read via 108c4a5ef6eSThomas Moestl.Xr kvm 3 109c4a5ef6eSThomas Moestlusing the supplied handle. 1108b7475edSRuslan ErmilovThe 111c4a5ef6eSThomas Moestl.Fn devstat_checkversion 1128b7475edSRuslan Ermilovfunction 113c4a5ef6eSThomas Moestlshould be called with each kvm handle that is going to be used (or with 114c4a5ef6eSThomas Moestl.Dv NULL 115c4a5ef6eSThomas Moestlif 116c4a5ef6eSThomas Moestl.Xr sysctl 3 117c4a5ef6eSThomas Moestlis going to be used). 11828fb27baSJustin T. Gibbs.Pp 1198b7475edSRuslan ErmilovThe 120c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs 1218b7475edSRuslan Ermilovfunction 12228fb27baSJustin T. Gibbsreturns the number of devices registered with the 1233b8ecdbbSRuslan Ermilov.Nm 12428fb27baSJustin T. Gibbssubsystem in the kernel. 12528fb27baSJustin T. Gibbs.Pp 1268b7475edSRuslan ErmilovThe 127c4a5ef6eSThomas Moestl.Fn devstat_getgeneration 1288b7475edSRuslan Ermilovfunction 12928fb27baSJustin T. Gibbsreturns the current generation of the 1303b8ecdbbSRuslan Ermilov.Nm 13128fb27baSJustin T. Gibbslist of devices in the kernel. 13228fb27baSJustin T. Gibbs.Pp 1338b7475edSRuslan ErmilovThe 134c4a5ef6eSThomas Moestl.Fn devstat_getversion 1358b7475edSRuslan Ermilovfunction 13628fb27baSJustin T. Gibbsreturns the current kernel 1373b8ecdbbSRuslan Ermilov.Nm 13828fb27baSJustin T. Gibbsversion. 13928fb27baSJustin T. Gibbs.Pp 1408b7475edSRuslan ErmilovThe 141c4a5ef6eSThomas Moestl.Fn devstat_checkversion 1428b7475edSRuslan Ermilovfunction 1438b7475edSRuslan Ermilovchecks the userland 1448b7475edSRuslan Ermilov.Nm 1458b7475edSRuslan Ermilovversion against the kernel 1468b7475edSRuslan Ermilov.Nm 1478b7475edSRuslan Ermilovversion. 148c4a5ef6eSThomas MoestlIf the two are identical, it returns zero. 149c4a5ef6eSThomas MoestlOtherwise, it prints an appropriate error in 15028fb27baSJustin T. Gibbs.Va devstat_errbuf 1518b7475edSRuslan Ermilovand returns \-1. 15228fb27baSJustin T. Gibbs.Pp 1538b7475edSRuslan ErmilovThe 154c4a5ef6eSThomas Moestl.Fn devstat_getdevs 1558b7475edSRuslan Ermilovfunction 15628fb27baSJustin T. Gibbsfetches the current list of devices and statistics into the supplied 1578b7475edSRuslan Ermilov.Vt statinfo 158c4a5ef6eSThomas Moestlstructure. 159c4a5ef6eSThomas MoestlThe 1608b7475edSRuslan Ermilov.Vt statinfo 16128fb27baSJustin T. Gibbsstructure can be found in 162fe08efe6SRuslan Ermilov.In devstat.h : 16328fb27baSJustin T. Gibbs.Bd -literal -offset indent 16428fb27baSJustin T. Gibbsstruct statinfo { 16528fb27baSJustin T. Gibbs long cp_time[CPUSTATES]; 16628fb27baSJustin T. Gibbs long tk_nin; 16728fb27baSJustin T. Gibbs long tk_nout; 16828fb27baSJustin T. Gibbs struct devinfo *dinfo; 169b193011aSPoul-Henning Kamp long double snap_time; 17028fb27baSJustin T. Gibbs}; 17128fb27baSJustin T. Gibbs.Ed 17228fb27baSJustin T. Gibbs.Pp 1738b7475edSRuslan ErmilovThe 174c4a5ef6eSThomas Moestl.Fn devstat_getdevs 1758b7475edSRuslan Ermilovfunction 17628fb27baSJustin T. Gibbsexpects the 1778b7475edSRuslan Ermilov.Vt statinfo 17828fb27baSJustin T. Gibbsstructure to be allocated, and it also expects the 17928fb27baSJustin T. Gibbs.Va dinfo 1806f83979dSKenneth D. Merrysubelement to be allocated and zeroed prior to the first invocation of 181c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 1826f83979dSKenneth D. MerryThe 1836f83979dSKenneth D. Merry.Va dinfo 1846f83979dSKenneth D. Merrysubelement is used to store state between calls, and should not be modified 1856f83979dSKenneth D. Merryafter the first call to 186c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 1876f83979dSKenneth D. MerryThe 18828fb27baSJustin T. Gibbs.Va dinfo 18928fb27baSJustin T. Gibbssubelement contains the following elements: 19028fb27baSJustin T. Gibbs.Bd -literal -offset indent 19128fb27baSJustin T. Gibbsstruct devinfo { 19228fb27baSJustin T. Gibbs struct devstat *devices; 19328fb27baSJustin T. Gibbs u_int8_t *mem_ptr; 194bcc6a3daSKenneth D. Merry long generation; 19528fb27baSJustin T. Gibbs int numdevs; 19628fb27baSJustin T. Gibbs}; 19728fb27baSJustin T. Gibbs.Ed 19828fb27baSJustin T. Gibbs.Pp 19928fb27baSJustin T. GibbsThe 20028fb27baSJustin T. Gibbs.Va kern.devstat.all 2018b7475edSRuslan Ermilov.Xr sysctl 8 20228fb27baSJustin T. Gibbsvariable contains an array of 2033b8ecdbbSRuslan Ermilov.Nm 20428fb27baSJustin T. Gibbsstructures, but at the head of the array is the current 2053b8ecdbbSRuslan Ermilov.Nm 206c4a5ef6eSThomas Moestlgeneration. 207c4a5ef6eSThomas MoestlThe reason the generation is at the head of the buffer is so that userland 2088b7475edSRuslan Ermilovsoftware accessing the 2098b7475edSRuslan Ermilov.Nm 2108b7475edSRuslan Ermilovstatistics information can atomically get 211c4a5ef6eSThomas Moestlboth the statistics information and the corresponding generation number. 212c4a5ef6eSThomas MoestlIf client software were forced to get the generation number via a separate 2138b7475edSRuslan Ermilov.Xr sysctl 8 21428fb27baSJustin T. Gibbsvariable (which is available for convenience), the list of devices could 21528fb27baSJustin T. Gibbschange between the time the client gets the generation and the time the 21628fb27baSJustin T. Gibbsclient gets the device list. 21728fb27baSJustin T. Gibbs.Pp 21828fb27baSJustin T. GibbsThe 21928fb27baSJustin T. Gibbs.Va mem_ptr 22028fb27baSJustin T. Gibbssubelement of the 2218b7475edSRuslan Ermilov.Vt devinfo 22228fb27baSJustin T. Gibbsstructure is a pointer to memory that is allocated, and resized if 22328fb27baSJustin T. Gibbsnecessary, by 224c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 22528fb27baSJustin T. GibbsThe devices subelement of the 2268b7475edSRuslan Ermilov.Vt devinfo 22728fb27baSJustin T. Gibbsstructure is basically a pointer to the beginning of the array of devstat 22828fb27baSJustin T. Gibbsstructures from the 22928fb27baSJustin T. Gibbs.Va kern.devstat.all 2308b7475edSRuslan Ermilov.Xr sysctl 8 231c4a5ef6eSThomas Moestlvariable (or the corresponding values read via 232c4a5ef6eSThomas Moestl.Xr kvm 3 ) . 233c4a5ef6eSThomas MoestlThe generation subelement of the 2348b7475edSRuslan Ermilov.Vt devinfo 235c4a5ef6eSThomas Moestlstructure contains the corresponding generation number. 23628fb27baSJustin T. GibbsThe 23728fb27baSJustin T. Gibbs.Va numdevs 23828fb27baSJustin T. Gibbssubelement of the 2398b7475edSRuslan Ermilov.Vt devinfo 24028fb27baSJustin T. Gibbsstructure contains the current 24128fb27baSJustin T. Gibbsnumber of devices registered with the kernel 2423b8ecdbbSRuslan Ermilov.Nm 24328fb27baSJustin T. Gibbssubsystem. 24428fb27baSJustin T. Gibbs.Pp 2458b7475edSRuslan ErmilovThe 246c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 2478b7475edSRuslan Ermilovfunction 24828fb27baSJustin T. Gibbsselects devices to display based upon a number of criteria: 2498b7475edSRuslan Ermilov.Bl -tag -width indent 25028fb27baSJustin T. Gibbs.It specified devices 251c4a5ef6eSThomas MoestlSpecified devices are the first selection priority. 2528b7475edSRuslan ErmilovThese are generally devices specified by name by the user e.g.\& 2538b7475edSRuslan Ermilov.Li da0 , da1 , cd0 . 25428fb27baSJustin T. Gibbs.It match patterns 25528fb27baSJustin T. GibbsThese are pattern matching expressions generated by 256c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 25728fb27baSJustin T. Gibbsfrom user input. 25828fb27baSJustin T. Gibbs.It performance 25928fb27baSJustin T. GibbsIf performance mode is enabled, devices will be sorted based on the 26028fb27baSJustin T. Gibbs.Va bytes 26128fb27baSJustin T. Gibbsfield in the 2628b7475edSRuslan Ermilov.Vt device_selection 26328fb27baSJustin T. Gibbsstructure passed in to 264c4a5ef6eSThomas Moestl.Fn devstat_selectdevs . 26528fb27baSJustin T. GibbsThe 26628fb27baSJustin T. Gibbs.Va bytes 267c4a5ef6eSThomas Moestlvalue currently must be maintained by the user. 268c4a5ef6eSThomas MoestlIn the future, this may be done for him in a 26928fb27baSJustin T. Gibbs.Nm 27028fb27baSJustin T. Gibbslibrary routine. 27128fb27baSJustin T. GibbsIf no devices have been selected by name or by pattern, the performance 27228fb27baSJustin T. Gibbstracking code will select every device in the system, and sort them by 273c4a5ef6eSThomas Moestlperformance. 274c4a5ef6eSThomas MoestlIf devices have been selected by name or pattern, the performance tracking 275c4a5ef6eSThomas Moestlcode will honor those selections and will only sort among the selected 276c4a5ef6eSThomas Moestldevices. 27728fb27baSJustin T. Gibbs.It order in the devstat list 2788b7475edSRuslan ErmilovIf the selection mode is set to 2798b7475edSRuslan Ermilov.Dv DS_SELECT_ADD , 2808b7475edSRuslan Ermilovand if there are still less 28128fb27baSJustin T. Gibbsthan 2828b7475edSRuslan Ermilov.Fa maxshowdevs 28328fb27baSJustin T. Gibbsdevices selected, 284c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 28528fb27baSJustin T. Gibbswill automatically select up to 2868b7475edSRuslan Ermilov.Fa maxshowdevs 28728fb27baSJustin T. Gibbsdevices. 28828fb27baSJustin T. Gibbs.El 28928fb27baSJustin T. Gibbs.Pp 2908b7475edSRuslan ErmilovThe 291c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 2928b7475edSRuslan Ermilovfunction 29328fb27baSJustin T. Gibbsperforms selections in four different modes: 2948b7475edSRuslan Ermilov.Bl -tag -width ".Dv DS_SELECT_ADDONLY" 2958b7475edSRuslan Ermilov.It Dv DS_SELECT_ADD 2968b7475edSRuslan ErmilovIn 2978b7475edSRuslan Ermilov.Dq add 2988b7475edSRuslan Ermilovmode, 299c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 30028fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern. 30128fb27baSJustin T. GibbsIt will also select more devices, in devstat list order, until the number 30228fb27baSJustin T. Gibbsof selected devices is equal to 3038b7475edSRuslan Ermilov.Fa maxshowdevs 30428fb27baSJustin T. Gibbsor until all devices are 30528fb27baSJustin T. Gibbsselected. 3068b7475edSRuslan Ermilov.It Dv DS_SELECT_ONLY 3078b7475edSRuslan ErmilovIn 3088b7475edSRuslan Ermilov.Dq only 3098b7475edSRuslan Ermilovmode, 310c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 31128fb27baSJustin T. Gibbswill clear all current selections, and will only select devices specified 31228fb27baSJustin T. Gibbsby name or by matching pattern. 3138b7475edSRuslan Ermilov.It Dv DS_SELECT_REMOVE 3148b7475edSRuslan ErmilovIn 3158b7475edSRuslan Ermilov.Dq remove 3168b7475edSRuslan Ermilovmode, 317c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 318c4a5ef6eSThomas Moestlwill remove devices specified by name or by matching pattern. 319c4a5ef6eSThomas MoestlIt will not select any additional devices. 3208b7475edSRuslan Ermilov.It Dv DS_SELECT_ADDONLY 3218b7475edSRuslan ErmilovIn 3228b7475edSRuslan Ermilov.Dq "add only" 3238b7475edSRuslan Ermilovmode, 324c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 32528fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern. 3268b7475edSRuslan ErmilovIn this respect it is identical to 3278b7475edSRuslan Ermilov.Dq add 3288b7475edSRuslan Ermilovmode. 329c4a5ef6eSThomas MoestlIt will not, however, select any devices other than those specified. 33028fb27baSJustin T. Gibbs.El 33128fb27baSJustin T. Gibbs.Pp 33228fb27baSJustin T. GibbsIn all selection modes, 333c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 33428fb27baSJustin T. Gibbswill not select any more than 3358b7475edSRuslan Ermilov.Fa maxshowdevs 336c4a5ef6eSThomas Moestldevices. 337c4a5ef6eSThomas MoestlOne exception to this is when you are in 33828fb27baSJustin T. Gibbs.Dq top 339c4a5ef6eSThomas Moestlmode and no devices have been selected. 340c4a5ef6eSThomas MoestlIn this case, 341c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 342c4a5ef6eSThomas Moestlwill select every device in the system. 343c4a5ef6eSThomas MoestlClient programs must pay attention to selection order when deciding whether 344c4a5ef6eSThomas Moestlto pay attention to a particular device. 345c4a5ef6eSThomas MoestlThis may be the wrong behavior, and probably requires additional thought. 34628fb27baSJustin T. Gibbs.Pp 3478b7475edSRuslan ErmilovThe 348c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 3498b7475edSRuslan Ermilovfunction 35028fb27baSJustin T. Gibbshandles allocation and resizing of the 3518b7475edSRuslan Ermilov.Fa dev_select 35228fb27baSJustin T. Gibbsstructure passed in 35328fb27baSJustin T. Gibbsby the client. 3548b7475edSRuslan ErmilovThe 355c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 3568b7475edSRuslan Ermilovfunction 35728fb27baSJustin T. Gibbsuses the 3588b7475edSRuslan Ermilov.Fa numdevs 35928fb27baSJustin T. Gibbsand 3608b7475edSRuslan Ermilov.Fa current_generation 36128fb27baSJustin T. Gibbsfields to track the 36228fb27baSJustin T. Gibbscurrent 36328fb27baSJustin T. Gibbs.Nm 364c4a5ef6eSThomas Moestlgeneration and number of devices. 365c4a5ef6eSThomas MoestlIf 3668b7475edSRuslan Ermilov.Fa num_selections 36728fb27baSJustin T. Gibbsis not the same 36828fb27baSJustin T. Gibbsas 3698b7475edSRuslan Ermilov.Fa numdevs 37028fb27baSJustin T. Gibbsor if 3718b7475edSRuslan Ermilov.Fa select_generation 37228fb27baSJustin T. Gibbsis not the same as 3738b7475edSRuslan Ermilov.Fa current_generation , 374c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 37528fb27baSJustin T. Gibbswill resize the selection list as necessary, and re-initialize the 37628fb27baSJustin T. Gibbsselection array. 37728fb27baSJustin T. Gibbs.Pp 3788b7475edSRuslan ErmilovThe 379c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 3808b7475edSRuslan Ermilovfunction 3818b7475edSRuslan Ermilovtakes a comma separated match string and compiles it into a 3828b7475edSRuslan Ermilov.Vt devstat_match 3838b7475edSRuslan Ermilovstructure that is understood by 3848b7475edSRuslan Ermilov.Fn devstat_selectdevs . 38528fb27baSJustin T. GibbsMatch strings have the following format: 38628fb27baSJustin T. Gibbs.Pp 3878b7475edSRuslan Ermilov.D1 Ar device , Ns Ar type , Ns Ar if 38828fb27baSJustin T. Gibbs.Pp 3898b7475edSRuslan ErmilovThe 390c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 3918b7475edSRuslan Ermilovfunction 39228fb27baSJustin T. Gibbstakes care of allocating and reallocating the match list as necessary. 39328fb27baSJustin T. GibbsCurrently known match types include: 3948b7475edSRuslan Ermilov.Bl -tag -width indent 39528fb27baSJustin T. Gibbs.It device type: 3968b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact 3978b7475edSRuslan Ermilov.It Li da 39828fb27baSJustin T. GibbsDirect Access devices 3998b7475edSRuslan Ermilov.It Li sa 40028fb27baSJustin T. GibbsSequential Access devices 4018b7475edSRuslan Ermilov.It Li printer 40228fb27baSJustin T. GibbsPrinters 4038b7475edSRuslan Ermilov.It Li proc 40428fb27baSJustin T. GibbsProcessor devices 4058b7475edSRuslan Ermilov.It Li worm 40628fb27baSJustin T. GibbsWrite Once Read Multiple devices 4078b7475edSRuslan Ermilov.It Li cd 40828fb27baSJustin T. GibbsCD devices 4098b7475edSRuslan Ermilov.It Li scanner 41028fb27baSJustin T. GibbsScanner devices 4118b7475edSRuslan Ermilov.It Li optical 41228fb27baSJustin T. GibbsOptical Memory devices 4138b7475edSRuslan Ermilov.It Li changer 41428fb27baSJustin T. GibbsMedium Changer devices 4158b7475edSRuslan Ermilov.It Li comm 41628fb27baSJustin T. GibbsCommunication devices 4178b7475edSRuslan Ermilov.It Li array 41828fb27baSJustin T. GibbsStorage Array devices 4198b7475edSRuslan Ermilov.It Li enclosure 42028fb27baSJustin T. GibbsEnclosure Services devices 4218b7475edSRuslan Ermilov.It Li floppy 42228fb27baSJustin T. GibbsFloppy devices 42328fb27baSJustin T. Gibbs.El 42428fb27baSJustin T. Gibbs.It interface: 4258b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact 4268b7475edSRuslan Ermilov.It Li IDE 42728fb27baSJustin T. GibbsIntegrated Drive Electronics devices 4288b7475edSRuslan Ermilov.It Li SCSI 42928fb27baSJustin T. GibbsSmall Computer System Interface devices 4308b7475edSRuslan Ermilov.It Li other 43128fb27baSJustin T. GibbsAny other device interface 43228fb27baSJustin T. Gibbs.El 43328fb27baSJustin T. Gibbs.It passthrough: 4348b7475edSRuslan Ermilov.Bl -tag -width ".Li enclosure" -compact 4358b7475edSRuslan Ermilov.It Li pass 43628fb27baSJustin T. GibbsPassthrough devices 43728fb27baSJustin T. Gibbs.El 43828fb27baSJustin T. Gibbs.El 43928fb27baSJustin T. Gibbs.Pp 4408b7475edSRuslan ErmilovThe 441c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 4428b7475edSRuslan Ermilovfunction 443c4a5ef6eSThomas Moestlis an updated version of 44428fb27baSJustin T. Gibbs.Fn compute_stats 445c4a5ef6eSThomas Moestlthat provides more 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 4758b7475edSRuslan Ermilov.Vt u_int64_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: 4928b7475edSRuslan Ermilov.Vt "u_int64_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: 5028b7475edSRuslan Ermilov.Vt "u_int64_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: 5118b7475edSRuslan Ermilov.Vt "u_int64_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: 5228b7475edSRuslan Ermilov.Vt "u_int64_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 . 5298b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS 5308b7475edSRuslan Ermilovtype: 5318b7475edSRuslan Ermilov.Vt "u_int64_t *" 532c4a5ef6eSThomas Moestl.Pp 533c4a5ef6eSThomas MoestlThe total number of blocks transferred between the acquisition of 5348b7475edSRuslan Ermilov.Fa previous 535c4a5ef6eSThomas Moestland 5368b7475edSRuslan Ermilov.Fa current . 537c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 5381a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default 539c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 5408b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_READ 5418b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_WRITE 5428b7475edSRuslan Ermilov.It Dv DSM_TOTAL_BLOCKS_FREE 5438b7475edSRuslan Ermilovtype: 5448b7475edSRuslan Ermilov.Vt "u_int64_t *" 545c4a5ef6eSThomas Moestl.Pp 546b193011aSPoul-Henning KampThe total number of blocks of the specified type between the acquisition of 5478b7475edSRuslan Ermilov.Fa previous 548c4a5ef6eSThomas Moestland 5498b7475edSRuslan Ermilov.Fa current . 550c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 5511a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default 552c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 5538b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER 5548b7475edSRuslan Ermilovtype: 5558b7475edSRuslan Ermilov.Vt "long double *" 556c4a5ef6eSThomas Moestl.Pp 557c4a5ef6eSThomas MoestlThe average number of kilobytes per transfer between the acquisition of 5588b7475edSRuslan Ermilov.Fa previous 559c4a5ef6eSThomas Moestland 5608b7475edSRuslan Ermilov.Fa current . 5618b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_READ 5628b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_WRITE 5638b7475edSRuslan Ermilov.It Dv DSM_KB_PER_TRANSFER_FREE 5648b7475edSRuslan Ermilovtype: 5658b7475edSRuslan Ermilov.Vt "long double *" 566c4a5ef6eSThomas Moestl.Pp 567b193011aSPoul-Henning KampThe average number of kilobytes in the specified type transaction between 568b193011aSPoul-Henning Kampthe acquisition of 5698b7475edSRuslan Ermilov.Fa previous 570c4a5ef6eSThomas Moestland 5718b7475edSRuslan Ermilov.Fa current . 5728b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND 5738b7475edSRuslan Ermilovtype: 5748b7475edSRuslan Ermilov.Vt "long double *" 575c4a5ef6eSThomas Moestl.Pp 576c4a5ef6eSThomas MoestlThe average number of transfers per second between the acquisition of 5778b7475edSRuslan Ermilov.Fa previous 578c4a5ef6eSThomas Moestland 5798b7475edSRuslan Ermilov.Fa current . 5808b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_OTHER 5818b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_READ 5828b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_WRITE 5838b7475edSRuslan Ermilov.It Dv DSM_TRANSFERS_PER_SECOND_FREE 5848b7475edSRuslan Ermilovtype: 5858b7475edSRuslan Ermilov.Vt "long double *" 586c4a5ef6eSThomas Moestl.Pp 587b193011aSPoul-Henning KampThe average number of transactions of the specified type per second 588b193011aSPoul-Henning Kampbetween the acquisition of 5898b7475edSRuslan Ermilov.Fa previous 590c4a5ef6eSThomas Moestland 5918b7475edSRuslan Ermilov.Fa current . 5928b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND 5938b7475edSRuslan Ermilovtype: 5948b7475edSRuslan Ermilov.Vt "long double *" 595c4a5ef6eSThomas Moestl.Pp 596c4a5ef6eSThomas MoestlThe average number of megabytes transferred per second between the 597c4a5ef6eSThomas Moestlacquisition of 5988b7475edSRuslan Ermilov.Fa previous 599c4a5ef6eSThomas Moestland 6008b7475edSRuslan Ermilov.Fa current . 6018b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_READ 6028b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_WRITE 6038b7475edSRuslan Ermilov.It Dv DSM_MB_PER_SECOND_FREE 6048b7475edSRuslan Ermilovtype: 6058b7475edSRuslan Ermilov.Vt "long double *" 606c4a5ef6eSThomas Moestl.Pp 607b193011aSPoul-Henning KampThe average number of megabytes per second in the specified type of 608b193011aSPoul-Henning Kamptransaction between the acquisition of 6098b7475edSRuslan Ermilov.Fa previous 610c4a5ef6eSThomas Moestland 6118b7475edSRuslan Ermilov.Fa current . 6128b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND 6138b7475edSRuslan Ermilovtype: 6148b7475edSRuslan Ermilov.Vt "long double *" 615c4a5ef6eSThomas Moestl.Pp 616c4a5ef6eSThomas MoestlThe average number of blocks transferred per second between the acquisition of 6178b7475edSRuslan Ermilov.Fa previous 618c4a5ef6eSThomas Moestland 6198b7475edSRuslan Ermilov.Fa current . 620c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 6211a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default 622c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 6238b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_READ 6248b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_WRITE 6258b7475edSRuslan Ermilov.It Dv DSM_BLOCKS_PER_SECOND_FREE 6268b7475edSRuslan Ermilovtype: 6278b7475edSRuslan Ermilov.Vt "long double *" 628c4a5ef6eSThomas Moestl.Pp 629b193011aSPoul-Henning KampThe average number of blocks per second in the specificed type of transaction 630b193011aSPoul-Henning Kampbetween the acquisition of 6318b7475edSRuslan Ermilov.Fa previous 632c4a5ef6eSThomas Moestland 6338b7475edSRuslan Ermilov.Fa current . 634c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 6351a0a9345SRuslan ErmilovIf no blocksize has been reported (i.e., the block size is 0), a default 636c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 6378b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION 6388b7475edSRuslan Ermilovtype: 6398b7475edSRuslan Ermilov.Vt "long double *" 640c4a5ef6eSThomas Moestl.Pp 641b193011aSPoul-Henning KampThe average duration of transactions between the acquisition of 6428b7475edSRuslan Ermilov.Fa previous 643c4a5ef6eSThomas Moestland 6448b7475edSRuslan Ermilov.Fa current . 6458b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_OTHER 6468b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_READ 6478b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_WRITE 6488b7475edSRuslan Ermilov.It Dv DSM_MS_PER_TRANSACTION_FREE 6498b7475edSRuslan Ermilovtype: 6508b7475edSRuslan Ermilov.Vt "long double *" 651c4a5ef6eSThomas Moestl.Pp 652b193011aSPoul-Henning KampThe average duration of transactions of the specified type between the 653b193011aSPoul-Henning Kampacquisition of 6548b7475edSRuslan Ermilov.Fa previous 655c4a5ef6eSThomas Moestland 6568b7475edSRuslan Ermilov.Fa current . 6578b7475edSRuslan Ermilov.It Dv DSM_BUSY_PCT 6588b7475edSRuslan Ermilovtype: 6598b7475edSRuslan Ermilov.Vt "long double *" 660b193011aSPoul-Henning Kamp.Pp 661b193011aSPoul-Henning KampThe percentage of time the device had one or more transactions outstanding 662b193011aSPoul-Henning Kampbetween the acquisition of 6638b7475edSRuslan Ermilov.Fa previous 664b193011aSPoul-Henning Kampand 6658b7475edSRuslan Ermilov.Fa current . 6668b7475edSRuslan Ermilov.It Dv DSM_QUEUE_LENGTH 6678b7475edSRuslan Ermilovtype: 6688b7475edSRuslan Ermilov.Vt "u_int64_t *" 669b193011aSPoul-Henning Kamp.Pp 670b193011aSPoul-Henning KampThe number of not yet completed transactions at the time when 6718b7475edSRuslan Ermilov.Fa current 672b193011aSPoul-Henning Kampwas acquired. 6738b7475edSRuslan Ermilov.It Dv DSM_SKIP 674884539f7SKenneth D. Merrytype: N/A 675884539f7SKenneth D. Merry.Pp 676884539f7SKenneth D. MerryIf you do not need a result from 677884539f7SKenneth D. Merry.Fn devstat_compute_statistics , 678884539f7SKenneth D. Merryjust put 6798b7475edSRuslan Ermilov.Dv DSM_SKIP 680884539f7SKenneth D. Merryas first (type) parameter and 6818b7475edSRuslan Ermilov.Dv NULL 682884539f7SKenneth D. Merryas second parameter. 683884539f7SKenneth D. MerryThis can be useful in scenarios where the statistics to be calculated 684884539f7SKenneth D. Merryare determined at run time. 685c4a5ef6eSThomas Moestl.El 686c4a5ef6eSThomas Moestl.Pp 687c4a5ef6eSThomas Moestl.Fn devstat_compute_etime 68828fb27baSJustin T. Gibbsprovides an easy way to find the difference in seconds between two 6898b7475edSRuslan Ermilov.Vt bintime 690c4a5ef6eSThomas Moestlstructures. 691c4a5ef6eSThomas MoestlThis is most commonly used in conjunction with the time recorded by the 692c4a5ef6eSThomas Moestl.Fn devstat_getdevs 6938b7475edSRuslan Ermilovfunction (in 6948b7475edSRuslan Ermilov.Vt "struct statinfo" ) 69528fb27baSJustin T. Gibbseach time it fetches the current 69628fb27baSJustin T. Gibbs.Nm 69728fb27baSJustin T. Gibbslist. 69828fb27baSJustin T. Gibbs.Sh RETURN VALUES 6998b7475edSRuslan ErmilovThe 700c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs , 701c4a5ef6eSThomas Moestl.Fn devstat_getgeneration , 70228fb27baSJustin T. Gibbsand 703c4a5ef6eSThomas Moestl.Fn devstat_getversion 7048b7475edSRuslan Ermilovfunction 7058b7475edSRuslan Ermilovreturn the indicated sysctl variable, or \-1 if there is an error 70628fb27baSJustin T. Gibbsfetching the variable. 70728fb27baSJustin T. Gibbs.Pp 7088b7475edSRuslan ErmilovThe 709c4a5ef6eSThomas Moestl.Fn devstat_checkversion 7108b7475edSRuslan Ermilovfunction 71128fb27baSJustin T. Gibbsreturns 0 if the kernel and userland 7123b8ecdbbSRuslan Ermilov.Nm 713c4a5ef6eSThomas Moestlversions match. 7148b7475edSRuslan ErmilovIf they do not match, it returns \-1. 71528fb27baSJustin T. Gibbs.Pp 7168b7475edSRuslan ErmilovThe 717c4a5ef6eSThomas Moestl.Fn devstat_getdevs 71828fb27baSJustin T. Gibbsand 719c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 7208b7475edSRuslan Ermilovfunctions 7218b7475edSRuslan Ermilovreturn \-1 in case of an error, 0 if there is no error, and 1 if the device 722c4a5ef6eSThomas Moestllist or selected devices have changed. 723c4a5ef6eSThomas MoestlA return value of 1 from 724c4a5ef6eSThomas Moestl.Fn devstat_getdevs 72528fb27baSJustin T. Gibbsis usually a hint to re-run 726c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 72728fb27baSJustin T. Gibbsbecause the device list has changed. 72828fb27baSJustin T. Gibbs.Pp 7298b7475edSRuslan ErmilovThe 730c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 7318b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 if there is no error. 73228fb27baSJustin T. Gibbs.Pp 7338b7475edSRuslan ErmilovThe 734c4a5ef6eSThomas Moestl.Fn devstat_compute_etime 7358b7475edSRuslan Ermilovfunction 73628fb27baSJustin T. Gibbsreturns the computed elapsed time. 73728fb27baSJustin T. Gibbs.Pp 7388b7475edSRuslan ErmilovThe 739c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 7408b7475edSRuslan Ermilovfunction returns \-1 for error, and 0 for success. 741c4a5ef6eSThomas Moestl.Pp 74228fb27baSJustin T. GibbsIf an error is returned from one of the 74328fb27baSJustin T. Gibbs.Nm 74428fb27baSJustin T. Gibbslibrary functions, the reason for the error is generally printed in 74528fb27baSJustin T. Gibbsthe global string 74628fb27baSJustin T. Gibbs.Va devstat_errbuf 74728fb27baSJustin T. Gibbswhich is 74828fb27baSJustin T. Gibbs.Dv DEVSTAT_ERRBUF_SIZE 74928fb27baSJustin T. Gibbscharacters long. 75028fb27baSJustin T. Gibbs.Sh SEE ALSO 75128fb27baSJustin T. Gibbs.Xr systat 1 , 752c4a5ef6eSThomas Moestl.Xr kvm 3 , 753c4a5ef6eSThomas Moestl.Xr sysctl 3 , 75428fb27baSJustin T. Gibbs.Xr iostat 8 , 75528fb27baSJustin T. Gibbs.Xr rpc.rstatd 8 , 756265c01dfSRuslan Ermilov.Xr sysctl 8 , 75728fb27baSJustin T. Gibbs.Xr vmstat 8 , 75828fb27baSJustin T. Gibbs.Xr devstat 9 75928fb27baSJustin T. Gibbs.Sh HISTORY 76028fb27baSJustin T. GibbsThe 76128fb27baSJustin T. Gibbs.Nm 76228fb27baSJustin T. Gibbsstatistics system first appeared in 76328fb27baSJustin T. Gibbs.Fx 3.0 . 7648b7475edSRuslan ErmilovThe new interface (the functions prefixed with 7658b7475edSRuslan Ermilov.Li devstat_ ) 7668b7475edSRuslan Ermilovfirst appeared in 767c4a5ef6eSThomas Moestl.Fx 5.0 . 76828fb27baSJustin T. Gibbs.Sh AUTHORS 769d0353b83SRuslan Ermilov.An Kenneth Merry Aq ken@FreeBSD.org 77028fb27baSJustin T. Gibbs.Sh BUGS 77128fb27baSJustin T. GibbsThere should probably be an interface to de-allocate memory allocated by 772c4a5ef6eSThomas Moestl.Fn devstat_getdevs , 773c4a5ef6eSThomas Moestl.Fn devstat_selectdevs , 77428fb27baSJustin T. Gibbsand 775c4a5ef6eSThomas Moestl.Fn devstat_buildmatch . 77628fb27baSJustin T. Gibbs.Pp 7778b7475edSRuslan ErmilovThe 778c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 7798b7475edSRuslan Ermilovfunction 78028fb27baSJustin T. Gibbsshould probably not select more than 7818b7475edSRuslan Ermilov.Fa maxshowdevs 78228fb27baSJustin T. Gibbsdevices in 78328fb27baSJustin T. Gibbs.Dq top 78428fb27baSJustin T. Gibbsmode when no devices have been selected previously. 78528fb27baSJustin T. Gibbs.Pp 78628fb27baSJustin T. GibbsThere should probably be functions to perform the statistics buffer 78728fb27baSJustin T. Gibbsswapping that goes on in most of the clients of this library. 78828fb27baSJustin T. Gibbs.Pp 78928fb27baSJustin T. GibbsThe 7908b7475edSRuslan Ermilov.Vt statinfo 79128fb27baSJustin T. Gibbsand 7928b7475edSRuslan Ermilov.Vt devinfo 79328fb27baSJustin T. Gibbsstructures should probably be cleaned up and thought out a little more. 794