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 431*d282baddSAlexander Motin.It Li NVME 432*d282baddSAlexander MotinNVM Express 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 . 529fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION 530fdd6757eSMikolaj Golubtype: 531fdd6757eSMikolaj Golub.Vt "long double *" 532fdd6757eSMikolaj Golub.Pp 533fdd6757eSMikolaj GolubThe total duration of transactions, in seconds, between the acquisition of 534fdd6757eSMikolaj Golub.Fa previous 535fdd6757eSMikolaj Goluband 536fdd6757eSMikolaj Golub.Fa current . 537fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_OTHER 538fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_READ 539fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_WRITE 540fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_DURATION_FREE 541fdd6757eSMikolaj Golubtype: 542fdd6757eSMikolaj Golub.Vt "long double *" 543fdd6757eSMikolaj Golub.Pp 544fdd6757eSMikolaj GolubThe total duration of transactions of the specified type between 545fdd6757eSMikolaj Golubthe acquisition of 546fdd6757eSMikolaj Golub.Fa previous 547fdd6757eSMikolaj Goluband 548fdd6757eSMikolaj Golub.Fa current . 549fdd6757eSMikolaj Golub.It Dv DSM_TOTAL_BUSY_TIME 550fdd6757eSMikolaj Golubtype: 551fdd6757eSMikolaj Golub.Vt "long double *" 552fdd6757eSMikolaj Golub.Pp 553fdd6757eSMikolaj GolubTotal time the device had one or more transactions outstanding 554fdd6757eSMikolaj Golubbetween the acquisition of 555fdd6757eSMikolaj Golub.Fa previous 556fdd6757eSMikolaj Goluband 557fdd6757eSMikolaj 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 8002b7af31cSBaptiste Daroussin.An Kenneth Merry Aq Mt 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