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.\" 30c4a5ef6eSThomas Moestl.Dd July 15, 2001 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 , 43c4a5ef6eSThomas Moestl.Nm devstat_compute_etime , 44b27e4ff3SAlexey Zelkin.Nm getnumdevs , 45b27e4ff3SAlexey Zelkin.Nm getgeneration , 46b27e4ff3SAlexey Zelkin.Nm getversion , 47b27e4ff3SAlexey Zelkin.Nm checkversion , 48b27e4ff3SAlexey Zelkin.Nm getdevs , 49b27e4ff3SAlexey Zelkin.Nm selectdevs , 50b27e4ff3SAlexey Zelkin.Nm buildmatch , 51b27e4ff3SAlexey Zelkin.Nm compute_stats , 52b27e4ff3SAlexey Zelkin.Nm compute_etime 5328fb27baSJustin T. Gibbs.Nd device statistics utility library 549d5b4f83SAlexey Zelkin.Sh LIBRARY 559d5b4f83SAlexey Zelkin.Lb libdevstat 5628fb27baSJustin T. Gibbs.Sh SYNOPSIS 57aedadd1cSBruce Evans.Fd #include <sys/dkstat.h> 5828fb27baSJustin T. Gibbs.Fd #include <devstat.h> 5928fb27baSJustin T. Gibbs.Ft int 60c4a5ef6eSThomas Moestl.Fo devstat_getnumdevs 61c4a5ef6eSThomas Moestl.Fa "kvm_t *kd" 62c4a5ef6eSThomas Moestl.Fc 63c4a5ef6eSThomas Moestl.Ft long 64c4a5ef6eSThomas Moestl.Fo devstat_getgeneration 65c4a5ef6eSThomas Moestl.Fa "kvm_t *kd" 66c4a5ef6eSThomas Moestl.Fc 67c4a5ef6eSThomas Moestl.Ft int 68c4a5ef6eSThomas Moestl.Fo devstat_getversion 69c4a5ef6eSThomas Moestl.Fa "kvm_t *kd" 70c4a5ef6eSThomas Moestl.Fc 71c4a5ef6eSThomas Moestl.Ft int 72c4a5ef6eSThomas Moestl.Fo devstat_checkversion 73c4a5ef6eSThomas Moestl.Fa "kvm_t *kd" 74c4a5ef6eSThomas Moestl.Fc 75c4a5ef6eSThomas Moestl.Ft int 76c4a5ef6eSThomas Moestl.Fo devstat_getdevs 77c4a5ef6eSThomas Moestl.Fa "kvm_t *kd" 78c4a5ef6eSThomas Moestl.Fa "struct statinfo *stats" 79c4a5ef6eSThomas Moestl.Fc 80c4a5ef6eSThomas Moestl.Ft int 81c4a5ef6eSThomas Moestl.Fo devstat_selectdevs 82c4a5ef6eSThomas Moestl.Fa "struct device_selection **dev_select" 83c4a5ef6eSThomas Moestl.Fa "int *num_selected" 84c4a5ef6eSThomas Moestl.Fa "int *num_selections" 85c4a5ef6eSThomas Moestl.Fa "long *select_generation" 86c4a5ef6eSThomas Moestl.Fa "long current_generation" 87c4a5ef6eSThomas Moestl.Fa "struct devstat *devices" 88c4a5ef6eSThomas Moestl.Fa "int numdevs" 89c4a5ef6eSThomas Moestl.Fa "struct devstat_match *matches" 90c4a5ef6eSThomas Moestl.Fa "int num_matches" 91c4a5ef6eSThomas Moestl.Fa "char **dev_selections" 92c4a5ef6eSThomas Moestl.Fa "int num_dev_selections" 93c4a5ef6eSThomas Moestl.Fa "devstat_select_mode select_mode" 94c4a5ef6eSThomas Moestl.Fa "int maxshowdevs" 95c4a5ef6eSThomas Moestl.Fa "int perf_select" 96c4a5ef6eSThomas Moestl.Fc 97c4a5ef6eSThomas Moestl.Ft int 98c4a5ef6eSThomas Moestl.Fo devstat_buildmatch 99c4a5ef6eSThomas Moestl.Fa "char *match_str" 100c4a5ef6eSThomas Moestl.Fa "struct devstat_match **matches" 101c4a5ef6eSThomas Moestl.Fa "int *num_matches" 102c4a5ef6eSThomas Moestl.Fc 103c4a5ef6eSThomas Moestl.Ft int 104c4a5ef6eSThomas Moestl.Fo devstat_compute_statistics 105c4a5ef6eSThomas Moestl.Fa "struct devstat *current" 106c4a5ef6eSThomas Moestl.Fa "struct devstat *previous" 107c4a5ef6eSThomas Moestl.Fa "long double *etime" 108c4a5ef6eSThomas Moestl.Fa "..." 109c4a5ef6eSThomas Moestl.Fc 110c4a5ef6eSThomas Moestl.Ft long double 111c4a5ef6eSThomas Moestl.Fo devstat_compute_etime 112c4a5ef6eSThomas Moestl.Fa "struct timeval cur_time" 113c4a5ef6eSThomas Moestl.Fa "struct timeval prev_time" 114c4a5ef6eSThomas Moestl.Fc 115c4a5ef6eSThomas Moestl.Ft int 11628fb27baSJustin T. Gibbs.Fn getnumdevs "void" 117bcc6a3daSKenneth D. Merry.Ft long 11828fb27baSJustin T. Gibbs.Fn getgeneration "void" 11928fb27baSJustin T. Gibbs.Ft int 12028fb27baSJustin T. Gibbs.Fn getversion "void" 12128fb27baSJustin T. Gibbs.Ft int 12228fb27baSJustin T. Gibbs.Fn checkversion "void" 12328fb27baSJustin T. Gibbs.Ft int 12428fb27baSJustin T. Gibbs.Fn getdevs "struct statinfo *stats" 12528fb27baSJustin T. Gibbs.Ft int 12628fb27baSJustin T. Gibbs.Fo selectdevs 12728fb27baSJustin T. Gibbs.Fa "struct device_selection **dev_select" 12828fb27baSJustin T. Gibbs.Fa "int *num_selected" 12928fb27baSJustin T. Gibbs.Fa "int *num_selections" 130bcc6a3daSKenneth D. Merry.Fa "long *select_generation" 131bcc6a3daSKenneth D. Merry.Fa "long current_generation" 13228fb27baSJustin T. Gibbs.Fa "struct devstat *devices" 13328fb27baSJustin T. Gibbs.Fa "int numdevs" 13428fb27baSJustin T. Gibbs.Fa "struct devstat_match *matches" 13528fb27baSJustin T. Gibbs.Fa "int num_matches" 13628fb27baSJustin T. Gibbs.Fa "char **dev_selections" 13728fb27baSJustin T. Gibbs.Fa "int num_dev_selections" 13828fb27baSJustin T. Gibbs.Fa "devstat_select_mode select_mode" 13928fb27baSJustin T. Gibbs.Fa "int maxshowdevs" 14028fb27baSJustin T. Gibbs.Fa "int perf_select" 14128fb27baSJustin T. Gibbs.Fc 14228fb27baSJustin T. Gibbs.Ft int 14328fb27baSJustin T. Gibbs.Fo buildmatch 14428fb27baSJustin T. Gibbs.Fa "char *match_str" 14528fb27baSJustin T. Gibbs.Fa "struct devstat_match **matches" 14628fb27baSJustin T. Gibbs.Fa "int *num_matches" 14728fb27baSJustin T. Gibbs.Fc 14828fb27baSJustin T. Gibbs.Ft int 14928fb27baSJustin T. Gibbs.Fo compute_stats 15028fb27baSJustin T. Gibbs.Fa "struct devstat *current" 15128fb27baSJustin T. Gibbs.Fa "struct devstat *previous" 15228fb27baSJustin T. Gibbs.Fa "long double etime" 15328fb27baSJustin T. Gibbs.Fa "u_int64_t *total_bytes" 15428fb27baSJustin T. Gibbs.Fa "u_int64_t *total_transfers" 15528fb27baSJustin T. Gibbs.Fa "u_int64_t *total_blocks" 15628fb27baSJustin T. Gibbs.Fa "long double *kb_per_transfer" 15728fb27baSJustin T. Gibbs.Fa "long double *transfers_per_second" 15828fb27baSJustin T. Gibbs.Fa "long double *mb_per_second" 15928fb27baSJustin T. Gibbs.Fa "long double *blocks_per_second" 16028fb27baSJustin T. Gibbs.Fa "long double *ms_per_transaction" 16128fb27baSJustin T. Gibbs.Fc 16228fb27baSJustin T. Gibbs.Ft long double 16328fb27baSJustin T. Gibbs.Fo compute_etime 16428fb27baSJustin T. Gibbs.Fa "struct timeval cur_time" 16528fb27baSJustin T. Gibbs.Fa "struct timeval prev_time" 16628fb27baSJustin T. Gibbs.Fc 16728fb27baSJustin T. Gibbs.Sh DESCRIPTION 16828fb27baSJustin T. GibbsThe 16928fb27baSJustin T. Gibbs.Nm 17028fb27baSJustin T. Gibbslibrary is a library of helper functions for dealing with the kernel 17128fb27baSJustin T. Gibbs.Xr devstat 9 17228fb27baSJustin T. Gibbsinterface, which is accessible to users via 173c4a5ef6eSThomas Moestl.Xr sysctl 3 174c4a5ef6eSThomas Moestland 175c4a5ef6eSThomas Moestl.Xr kvm 3 . 176b9154997SKenneth D. MerryAll functions that take a 177c4a5ef6eSThomas Moestl.Vt kvm_t * 178c4a5ef6eSThomas Moestlas first argument can be passed 179c4a5ef6eSThomas Moestl.Dv NULL 180c4a5ef6eSThomas Moestlinstead of a kvm handle as this argument, 181c4a5ef6eSThomas Moestlwhich causes the data to be read via 18228fb27baSJustin T. Gibbs.Xr sysctl 3 . 183c4a5ef6eSThomas MoestlOtherwise, it is read via 184c4a5ef6eSThomas Moestl.Xr kvm 3 185c4a5ef6eSThomas Moestlusing the supplied handle. 186c4a5ef6eSThomas Moestl.Fn devstat_checkversion 187c4a5ef6eSThomas Moestlshould be called with each kvm handle that is going to be used (or with 188c4a5ef6eSThomas Moestl.Dv NULL 189c4a5ef6eSThomas Moestlif 190c4a5ef6eSThomas Moestl.Xr sysctl 3 191c4a5ef6eSThomas Moestlis going to be used). 19228fb27baSJustin T. Gibbs.Pp 193c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs 19428fb27baSJustin T. Gibbsreturns the number of devices registered with the 1953b8ecdbbSRuslan Ermilov.Nm 19628fb27baSJustin T. Gibbssubsystem in the kernel. 19728fb27baSJustin T. Gibbs.Pp 198c4a5ef6eSThomas Moestl.Fn getnumdevs 199c4a5ef6eSThomas Moestlis a deprecated version of 200c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs 201c4a5ef6eSThomas Moestlwhich always uses 202c4a5ef6eSThomas Moestl.Xr sysctl 3 . 203c4a5ef6eSThomas Moestl.Pp 204c4a5ef6eSThomas Moestl.Fn devstat_getgeneration 20528fb27baSJustin T. Gibbsreturns the current generation of the 2063b8ecdbbSRuslan Ermilov.Nm 20728fb27baSJustin T. Gibbslist of devices in the kernel. 20828fb27baSJustin T. Gibbs.Pp 209c4a5ef6eSThomas Moestl.Fn getgeneration 210c4a5ef6eSThomas Moestlis a deprecated version of 211c4a5ef6eSThomas Moestl.Fn devstat_getgeneration 212c4a5ef6eSThomas Moestlwhich always uses 213c4a5ef6eSThomas Moestl.Xr sysctl 3 . 214c4a5ef6eSThomas Moestl.Pp 215c4a5ef6eSThomas Moestl.Fn devstat_getversion 21628fb27baSJustin T. Gibbsreturns the current kernel 2173b8ecdbbSRuslan Ermilov.Nm 21828fb27baSJustin T. Gibbsversion. 21928fb27baSJustin T. Gibbs.Pp 220c4a5ef6eSThomas Moestl.Fn getversion 221c4a5ef6eSThomas Moestlis a deprecated version of 222c4a5ef6eSThomas Moestl.Fn devstat_getversion 223c4a5ef6eSThomas Moestlwhich always uses 224c4a5ef6eSThomas Moestl.Xr sysctl 3 . 225c4a5ef6eSThomas Moestl.Pp 226c4a5ef6eSThomas Moestl.Fn devstat_checkversion 227c4a5ef6eSThomas Moestlchecks the userland devstat version against the kernel devstat version. 228c4a5ef6eSThomas MoestlIf the two are identical, it returns zero. 229c4a5ef6eSThomas MoestlOtherwise, it prints an appropriate error in 23028fb27baSJustin T. Gibbs.Va devstat_errbuf 23128fb27baSJustin T. Gibbsand returns -1. 23228fb27baSJustin T. Gibbs.Pp 233c4a5ef6eSThomas Moestl.Fn checkversion 234c4a5ef6eSThomas Moestlis a deprecated version of 235c4a5ef6eSThomas Moestl.Fn devstat_checkversion 236c4a5ef6eSThomas Moestlwhich always uses 237c4a5ef6eSThomas Moestl.Xr sysctl 3 . 238c4a5ef6eSThomas Moestl.Pp 239c4a5ef6eSThomas Moestl.Fn devstat_getdevs 24028fb27baSJustin T. Gibbsfetches the current list of devices and statistics into the supplied 24128fb27baSJustin T. Gibbs.Va statinfo 242c4a5ef6eSThomas Moestlstructure. 243c4a5ef6eSThomas MoestlThe 24428fb27baSJustin T. Gibbs.Va statinfo 24528fb27baSJustin T. Gibbsstructure can be found in 24628fb27baSJustin T. Gibbs.Aq Pa devstat.h : 24728fb27baSJustin T. Gibbs.Bd -literal -offset indent 24828fb27baSJustin T. Gibbsstruct statinfo { 24928fb27baSJustin T. Gibbs long cp_time[CPUSTATES]; 25028fb27baSJustin T. Gibbs long tk_nin; 25128fb27baSJustin T. Gibbs long tk_nout; 25228fb27baSJustin T. Gibbs struct devinfo *dinfo; 25328fb27baSJustin T. Gibbs struct timeval busy_time; 25428fb27baSJustin T. Gibbs}; 25528fb27baSJustin T. Gibbs.Ed 25628fb27baSJustin T. Gibbs.Pp 257c4a5ef6eSThomas Moestl.Fn devstat_getdevs 25828fb27baSJustin T. Gibbsexpects the 25928fb27baSJustin T. Gibbs.Va statinfo 26028fb27baSJustin T. Gibbsstructure to be allocated, and it also expects the 26128fb27baSJustin T. Gibbs.Va dinfo 2626f83979dSKenneth D. Merrysubelement to be allocated and zeroed prior to the first invocation of 263c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 2646f83979dSKenneth D. MerryThe 2656f83979dSKenneth D. Merry.Va dinfo 2666f83979dSKenneth D. Merrysubelement is used to store state between calls, and should not be modified 2676f83979dSKenneth D. Merryafter the first call to 268c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 2696f83979dSKenneth D. MerryThe 27028fb27baSJustin T. Gibbs.Va dinfo 27128fb27baSJustin T. Gibbssubelement contains the following elements: 27228fb27baSJustin T. Gibbs.Bd -literal -offset indent 27328fb27baSJustin T. Gibbsstruct devinfo { 27428fb27baSJustin T. Gibbs struct devstat *devices; 27528fb27baSJustin T. Gibbs u_int8_t *mem_ptr; 276bcc6a3daSKenneth D. Merry long generation; 27728fb27baSJustin T. Gibbs int numdevs; 27828fb27baSJustin T. Gibbs}; 27928fb27baSJustin T. Gibbs.Ed 28028fb27baSJustin T. Gibbs.Pp 28128fb27baSJustin T. GibbsThe 28228fb27baSJustin T. Gibbs.Va kern.devstat.all 28328fb27baSJustin T. Gibbs.Nm sysctl 28428fb27baSJustin T. Gibbsvariable contains an array of 2853b8ecdbbSRuslan Ermilov.Nm 28628fb27baSJustin T. Gibbsstructures, but at the head of the array is the current 2873b8ecdbbSRuslan Ermilov.Nm 288c4a5ef6eSThomas Moestlgeneration. 289c4a5ef6eSThomas MoestlThe reason the generation is at the head of the buffer is so that userland 290c4a5ef6eSThomas Moestlsoftware accessing the devstat statistics information can atomically get 291c4a5ef6eSThomas Moestlboth the statistics information and the corresponding generation number. 292c4a5ef6eSThomas MoestlIf client software were forced to get the generation number via a separate 29328fb27baSJustin T. Gibbs.Nm sysctl 29428fb27baSJustin T. Gibbsvariable (which is available for convenience), the list of devices could 29528fb27baSJustin T. Gibbschange between the time the client gets the generation and the time the 29628fb27baSJustin T. Gibbsclient gets the device list. 29728fb27baSJustin T. Gibbs.Pp 29828fb27baSJustin T. GibbsThe 29928fb27baSJustin T. Gibbs.Va mem_ptr 30028fb27baSJustin T. Gibbssubelement of the 30128fb27baSJustin T. Gibbs.Va devinfo 30228fb27baSJustin T. Gibbsstructure is a pointer to memory that is allocated, and resized if 30328fb27baSJustin T. Gibbsnecessary, by 304c4a5ef6eSThomas Moestl.Fn devstat_getdevs . 30528fb27baSJustin T. GibbsThe devices subelement of the 30628fb27baSJustin T. Gibbs.Va devinfo 30728fb27baSJustin T. Gibbsstructure is basically a pointer to the beginning of the array of devstat 30828fb27baSJustin T. Gibbsstructures from the 30928fb27baSJustin T. Gibbs.Va kern.devstat.all 31028fb27baSJustin T. Gibbs.Nm sysctl 311c4a5ef6eSThomas Moestlvariable (or the corresponding values read via 312c4a5ef6eSThomas Moestl.Xr kvm 3 ) . 313c4a5ef6eSThomas MoestlThe generation subelement of the 3143b8ecdbbSRuslan Ermilov.Va devinfo 315c4a5ef6eSThomas Moestlstructure contains the corresponding generation number. 31628fb27baSJustin T. GibbsThe 31728fb27baSJustin T. Gibbs.Va numdevs 31828fb27baSJustin T. Gibbssubelement of the 31928fb27baSJustin T. Gibbs.Va devinfo 32028fb27baSJustin T. Gibbsstructure contains the current 32128fb27baSJustin T. Gibbsnumber of devices registered with the kernel 3223b8ecdbbSRuslan Ermilov.Nm 32328fb27baSJustin T. Gibbssubsystem. 32428fb27baSJustin T. Gibbs.Pp 325c4a5ef6eSThomas Moestl.Fn getdevs 326c4a5ef6eSThomas Moestlis a deprecated version of 327c4a5ef6eSThomas Moestl.Fn devstat_getdevs 328c4a5ef6eSThomas Moestlwhich always uses 329c4a5ef6eSThomas Moestl.Xr sysctl 3 . 330c4a5ef6eSThomas Moestl.Pp 331c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 33228fb27baSJustin T. Gibbsselects devices to display based upon a number of criteria: 33328fb27baSJustin T. Gibbs.Bl -tag -width flag 33428fb27baSJustin T. Gibbs.It specified devices 335c4a5ef6eSThomas MoestlSpecified devices are the first selection priority. 336c4a5ef6eSThomas MoestlThese are generally devices specified by name by the user e.g. da0, da1, cd0. 33728fb27baSJustin T. Gibbs.It match patterns 33828fb27baSJustin T. GibbsThese are pattern matching expressions generated by 339c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 34028fb27baSJustin T. Gibbsfrom user input. 34128fb27baSJustin T. Gibbs.It performance 34228fb27baSJustin T. GibbsIf performance mode is enabled, devices will be sorted based on the 34328fb27baSJustin T. Gibbs.Va bytes 34428fb27baSJustin T. Gibbsfield in the 34528fb27baSJustin T. Gibbs.Va device_selection 34628fb27baSJustin T. Gibbsstructure passed in to 347c4a5ef6eSThomas Moestl.Fn devstat_selectdevs . 34828fb27baSJustin T. GibbsThe 34928fb27baSJustin T. Gibbs.Va bytes 350c4a5ef6eSThomas Moestlvalue currently must be maintained by the user. 351c4a5ef6eSThomas MoestlIn the future, this may be done for him in a 35228fb27baSJustin T. Gibbs.Nm 35328fb27baSJustin T. Gibbslibrary routine. 35428fb27baSJustin T. GibbsIf no devices have been selected by name or by pattern, the performance 35528fb27baSJustin T. Gibbstracking code will select every device in the system, and sort them by 356c4a5ef6eSThomas Moestlperformance. 357c4a5ef6eSThomas MoestlIf devices have been selected by name or pattern, the performance tracking 358c4a5ef6eSThomas Moestlcode will honor those selections and will only sort among the selected 359c4a5ef6eSThomas Moestldevices. 36028fb27baSJustin T. Gibbs.It order in the devstat list 36128fb27baSJustin T. GibbsIf the selection mode is set to DS_SELECT_ADD, and if there are still less 36228fb27baSJustin T. Gibbsthan 36328fb27baSJustin T. Gibbs.Va maxshowdevs 36428fb27baSJustin T. Gibbsdevices selected, 365c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 36628fb27baSJustin T. Gibbswill automatically select up to 36728fb27baSJustin T. Gibbs.Va maxshowdevs 36828fb27baSJustin T. Gibbsdevices. 36928fb27baSJustin T. Gibbs.El 37028fb27baSJustin T. Gibbs.Pp 371c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 37228fb27baSJustin T. Gibbsperforms selections in four different modes: 37328fb27baSJustin T. Gibbs.Bl -tag -width DS_SELECT_ADDONLY 37428fb27baSJustin T. Gibbs.It DS_SELECT_ADD 37528fb27baSJustin T. GibbsIn add mode, 376c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 37728fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern. 37828fb27baSJustin T. GibbsIt will also select more devices, in devstat list order, until the number 37928fb27baSJustin T. Gibbsof selected devices is equal to 38028fb27baSJustin T. Gibbs.Va maxshowdevs 38128fb27baSJustin T. Gibbsor until all devices are 38228fb27baSJustin T. Gibbsselected. 38328fb27baSJustin T. Gibbs.It DS_SELECT_ONLY 38428fb27baSJustin T. GibbsIn only mode, 385c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 38628fb27baSJustin T. Gibbswill clear all current selections, and will only select devices specified 38728fb27baSJustin T. Gibbsby name or by matching pattern. 38828fb27baSJustin T. Gibbs.It DS_SELECT_REMOVE 38928fb27baSJustin T. GibbsIn remove mode, 390c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 391c4a5ef6eSThomas Moestlwill remove devices specified by name or by matching pattern. 392c4a5ef6eSThomas MoestlIt will not select any additional devices. 39328fb27baSJustin T. Gibbs.It DS_SELECT_ADDONLY 39428fb27baSJustin T. GibbsIn add only mode, 395c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 39628fb27baSJustin T. Gibbswill select any unselected devices specified by name or matching pattern. 397c4a5ef6eSThomas MoestlIn this respect it is identical to add mode. 398c4a5ef6eSThomas MoestlIt will not, however, select any devices other than those specified. 39928fb27baSJustin T. Gibbs.El 40028fb27baSJustin T. Gibbs.Pp 40128fb27baSJustin T. GibbsIn all selection modes, 402c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 40328fb27baSJustin T. Gibbswill not select any more than 40428fb27baSJustin T. Gibbs.Va maxshowdevs 405c4a5ef6eSThomas Moestldevices. 406c4a5ef6eSThomas MoestlOne exception to this is when you are in 40728fb27baSJustin T. Gibbs.Dq top 408c4a5ef6eSThomas Moestlmode and no devices have been selected. 409c4a5ef6eSThomas MoestlIn this case, 410c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 411c4a5ef6eSThomas Moestlwill select every device in the system. 412c4a5ef6eSThomas MoestlClient programs must pay attention to selection order when deciding whether 413c4a5ef6eSThomas Moestlto pay attention to a particular device. 414c4a5ef6eSThomas MoestlThis may be the wrong behavior, and probably requires additional thought. 41528fb27baSJustin T. Gibbs.Pp 416c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 41728fb27baSJustin T. Gibbshandles allocation and resizing of the 41828fb27baSJustin T. Gibbs.Va dev_select 41928fb27baSJustin T. Gibbsstructure passed in 42028fb27baSJustin T. Gibbsby the client. 421c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 42228fb27baSJustin T. Gibbsuses the 42328fb27baSJustin T. Gibbs.Va numdevs 42428fb27baSJustin T. Gibbsand 42528fb27baSJustin T. Gibbs.Va current_generation 42628fb27baSJustin T. Gibbsfields to track the 42728fb27baSJustin T. Gibbscurrent 42828fb27baSJustin T. Gibbs.Nm 429c4a5ef6eSThomas Moestlgeneration and number of devices. 430c4a5ef6eSThomas MoestlIf 43128fb27baSJustin T. Gibbs.Va num_selections 43228fb27baSJustin T. Gibbsis not the same 43328fb27baSJustin T. Gibbsas 43428fb27baSJustin T. Gibbs.Va numdevs 43528fb27baSJustin T. Gibbsor if 43628fb27baSJustin T. Gibbs.Va select_generation 43728fb27baSJustin T. Gibbsis not the same as 43828fb27baSJustin T. Gibbs.Va current_generation , 439c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 44028fb27baSJustin T. Gibbswill resize the selection list as necessary, and re-initialize the 44128fb27baSJustin T. Gibbsselection array. 44228fb27baSJustin T. Gibbs.Pp 443c4a5ef6eSThomas Moestl.Fn selectdevs 444c4a5ef6eSThomas Moestlis the old name of 445c4a5ef6eSThomas Moestl.Fn devstat_selectdevs , 446c4a5ef6eSThomas Moestland is deprecated. 447c4a5ef6eSThomas Moestl.Pp 448c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 449c4a5ef6eSThomas Moestltake a comma separated match string and compile it into a 45028fb27baSJustin T. Gibbs\fBdevstat_match\fR structure that is understood by 45128fb27baSJustin T. Gibbs.Fn selectdevs . 45228fb27baSJustin T. GibbsMatch strings have the following format: 45328fb27baSJustin T. Gibbs.Pp 45428fb27baSJustin T. Gibbs.Bd -literal -offset indent 45528fb27baSJustin T. Gibbsdevice,type,if 45628fb27baSJustin T. Gibbs.Ed 45728fb27baSJustin T. Gibbs.Pp 458c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 45928fb27baSJustin T. Gibbstakes care of allocating and reallocating the match list as necessary. 46028fb27baSJustin T. GibbsCurrently known match types include: 46128fb27baSJustin T. Gibbs.Pp 46228fb27baSJustin T. Gibbs.Bl -tag -width indent -compact 46328fb27baSJustin T. Gibbs.It device type: 46442635956SRuslan Ermilov.Bl -tag -width 9n -compact 46528fb27baSJustin T. Gibbs.It da 46628fb27baSJustin T. GibbsDirect Access devices 46728fb27baSJustin T. Gibbs.It sa 46828fb27baSJustin T. GibbsSequential Access devices 46928fb27baSJustin T. Gibbs.It printer 47028fb27baSJustin T. GibbsPrinters 47128fb27baSJustin T. Gibbs.It proc 47228fb27baSJustin T. GibbsProcessor devices 47328fb27baSJustin T. Gibbs.It worm 47428fb27baSJustin T. GibbsWrite Once Read Multiple devices 47528fb27baSJustin T. Gibbs.It cd 47628fb27baSJustin T. GibbsCD devices 47728fb27baSJustin T. Gibbs.It scanner 47828fb27baSJustin T. GibbsScanner devices 47928fb27baSJustin T. Gibbs.It optical 48028fb27baSJustin T. GibbsOptical Memory devices 48128fb27baSJustin T. Gibbs.It changer 48228fb27baSJustin T. GibbsMedium Changer devices 48328fb27baSJustin T. Gibbs.It comm 48428fb27baSJustin T. GibbsCommunication devices 48528fb27baSJustin T. Gibbs.It array 48628fb27baSJustin T. GibbsStorage Array devices 48728fb27baSJustin T. Gibbs.It enclosure 48828fb27baSJustin T. GibbsEnclosure Services devices 48928fb27baSJustin T. Gibbs.It floppy 49028fb27baSJustin T. GibbsFloppy devices 49128fb27baSJustin T. Gibbs.El 49228fb27baSJustin T. Gibbs.Pp 49328fb27baSJustin T. Gibbs.It interface: 49442635956SRuslan Ermilov.Bl -tag -width 9n -compact 49528fb27baSJustin T. Gibbs.It IDE 49628fb27baSJustin T. GibbsIntegrated Drive Electronics devices 49728fb27baSJustin T. Gibbs.It SCSI 49828fb27baSJustin T. GibbsSmall Computer System Interface devices 49928fb27baSJustin T. Gibbs.It other 50028fb27baSJustin T. GibbsAny other device interface 50128fb27baSJustin T. Gibbs.El 50228fb27baSJustin T. Gibbs.Pp 50328fb27baSJustin T. Gibbs.It passthrough: 50442635956SRuslan Ermilov.Bl -tag -width 9n -compact 50528fb27baSJustin T. Gibbs.It pass 50628fb27baSJustin T. GibbsPassthrough devices 50728fb27baSJustin T. Gibbs.El 50828fb27baSJustin T. Gibbs.El 50928fb27baSJustin T. Gibbs.Pp 510c4a5ef6eSThomas Moestl.Fn buildmatch 511c4a5ef6eSThomas Moestlis the old name of 512c4a5ef6eSThomas Moestl.Fn devstat_buildmatch , 513c4a5ef6eSThomas Moestland is deprecated. 514c4a5ef6eSThomas Moestl.Pp 515c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 516c4a5ef6eSThomas Moestlis an updated version of 51728fb27baSJustin T. Gibbs.Fn compute_stats 518c4a5ef6eSThomas Moestlthat provides more complete statistics calculation. 519c4a5ef6eSThomas MoestlThere are four arguments for which values \fBmust\fR be supplied: 520c4a5ef6eSThomas Moestl.Va current , 521c4a5ef6eSThomas Moestl.Va previous , 522c4a5ef6eSThomas Moestl.Va etime , 523c4a5ef6eSThomas Moestland the terminating argument for the varargs list, 524c4a5ef6eSThomas Moestl.Va DSM_NONE . 525c4a5ef6eSThomas MoestlFor most applications, the user will want to supply valid devstat 526c4a5ef6eSThomas Moestlstructures for both 527c4a5ef6eSThomas Moestl.Va current 528c4a5ef6eSThomas Moestland 529c4a5ef6eSThomas Moestl.Va previous . 530c4a5ef6eSThomas MoestlIn some instances, for instance when calculating statistics since system 531c4a5ef6eSThomas Moestlboot, the user may pass in a NULL pointer for the 532c4a5ef6eSThomas Moestl.Va previous 533c4a5ef6eSThomas Moestlargument. 534c4a5ef6eSThomas MoestlIn that case, 535c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 536c4a5ef6eSThomas Moestlwill use the total stats in the 537c4a5ef6eSThomas Moestl.Va current 538c4a5ef6eSThomas Moestlstructure to calculate statistics over 539c4a5ef6eSThomas Moestl.Va etime . 540c4a5ef6eSThomas MoestlFor each statistic to be calculated, the user should supply the proper 541c4a5ef6eSThomas Moestlenumerated type (listed below), and a variable of the indicated type. 542c4a5ef6eSThomas MoestlAll statistics are either integer values, for which a u_int64_t is used, 543c4a5ef6eSThomas Moestlor floating point, for which a long double is used. 544c4a5ef6eSThomas MoestlThe statistics that may be calculated are: 545c4a5ef6eSThomas Moestl.Bl -tag -width DSM_TRANSFERS_PER_SECOND_OTHER 546c4a5ef6eSThomas Moestl.It DSM_NONE 547c4a5ef6eSThomas Moestltype: N/A 548c4a5ef6eSThomas Moestl.Pp 549c4a5ef6eSThomas MoestlThis \fBmust\fR 550c4a5ef6eSThomas Moestlbe the last argument passed to 551c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics . 552c4a5ef6eSThomas MoestlIt is an argument list terminator. 553c4a5ef6eSThomas Moestl.It DSM_TOTAL_BYTES 554c4a5ef6eSThomas Moestltype: u_int64_t * 555c4a5ef6eSThomas Moestl.Pp 556c4a5ef6eSThomas MoestlThe total number of bytes transferred between the acquisition of 557c4a5ef6eSThomas Moestl.Va previous 558c4a5ef6eSThomas Moestland 559c4a5ef6eSThomas Moestl.Va current . 560c4a5ef6eSThomas Moestl.It DSM_TOTAL_BYTES_READ 561c4a5ef6eSThomas Moestltype: u_int64_t * 562c4a5ef6eSThomas Moestl.Pp 563c4a5ef6eSThomas MoestlThe total number of bytes read between the acquisition of 564c4a5ef6eSThomas Moestl.Va previous 565c4a5ef6eSThomas Moestland 566c4a5ef6eSThomas Moestl.Va current . 567c4a5ef6eSThomas Moestl.It DSM_TOTAL_BYTES_WRITE 568c4a5ef6eSThomas Moestltype: u_int64_t * 569c4a5ef6eSThomas Moestl.Pp 570c4a5ef6eSThomas MoestlThe total number of bytes written between the acquisition of 571c4a5ef6eSThomas Moestl.Va previous 572c4a5ef6eSThomas Moestland 573c4a5ef6eSThomas Moestl.Va current . 574c4a5ef6eSThomas Moestl.It DSM_TOTAL_TRANSFERS 575c4a5ef6eSThomas Moestltype: u_int64_t * 576c4a5ef6eSThomas Moestl.Pp 577c4a5ef6eSThomas MoestlThe total number of transfers between the acquisition of 578c4a5ef6eSThomas Moestl.Va previous 579c4a5ef6eSThomas Moestland 580c4a5ef6eSThomas Moestl.Va current . 581c4a5ef6eSThomas Moestl.It DSM_TOTAL_TRANSFERS_READ 582c4a5ef6eSThomas Moestltype: u_int64_t * 583c4a5ef6eSThomas Moestl.Pp 584c4a5ef6eSThomas MoestlThe total number of reads between the acquisition of 585c4a5ef6eSThomas Moestl.Va previous 586c4a5ef6eSThomas Moestland 587c4a5ef6eSThomas Moestl.Va current . 588c4a5ef6eSThomas Moestl.It DSM_TOTAL_TRANSFERS_WRITE 589c4a5ef6eSThomas Moestltype: u_int64_t * 590c4a5ef6eSThomas Moestl.Pp 591c4a5ef6eSThomas MoestlThe total number of writes between the acquisition of 592c4a5ef6eSThomas Moestl.Va previous 593c4a5ef6eSThomas Moestland 594c4a5ef6eSThomas Moestl.Va current . 595c4a5ef6eSThomas Moestl.It DSM_TOTAL_TRANSFERS_OTHER 596c4a5ef6eSThomas Moestltype: u_int64_t * 597c4a5ef6eSThomas Moestl.Pp 598c4a5ef6eSThomas MoestlThe total number of transactions that are not reads or writes that occurred 599c4a5ef6eSThomas Moestlbetween the acquisition of 600c4a5ef6eSThomas Moestl.Va previous 601c4a5ef6eSThomas Moestland 602c4a5ef6eSThomas Moestl.Va current . 603c4a5ef6eSThomas Moestl.It DSM_TOTAL_BLOCKS 604c4a5ef6eSThomas Moestltype: u_int64_t * 605c4a5ef6eSThomas Moestl.Pp 606c4a5ef6eSThomas MoestlThe total number of blocks transferred between the acquisition of 607c4a5ef6eSThomas Moestl.Va previous 608c4a5ef6eSThomas Moestland 609c4a5ef6eSThomas Moestl.Va current . 610c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 611c4a5ef6eSThomas MoestlIf no blocksize has been reported (i.e. the block size is 0), a default 612c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 613c4a5ef6eSThomas Moestl.It DSM_TOTAL_BLOCKS_READ 614c4a5ef6eSThomas Moestltype: u_int64_t * 615c4a5ef6eSThomas Moestl.Pp 616c4a5ef6eSThomas MoestlThe total number of blocks read between the acquisition of 617c4a5ef6eSThomas Moestl.Va previous 618c4a5ef6eSThomas Moestland 619c4a5ef6eSThomas Moestl.Va current . 620c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 621c4a5ef6eSThomas MoestlIf 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. 623c4a5ef6eSThomas Moestl.It DSM_TOTAL_BLOCKS_WRITE 624c4a5ef6eSThomas Moestltype: u_int64_t * 625c4a5ef6eSThomas Moestl.Pp 626c4a5ef6eSThomas MoestlThe total number of blocks written between the acquisition of 627c4a5ef6eSThomas Moestl.Va previous 628c4a5ef6eSThomas Moestland 629c4a5ef6eSThomas Moestl.Va current . 630c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 631c4a5ef6eSThomas MoestlIf no blocksize has been reported (i.e. the block size is 0), a default 632c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 633c4a5ef6eSThomas Moestl.It DSM_KB_PER_TRANSFER 634c4a5ef6eSThomas Moestltype: long double * 635c4a5ef6eSThomas Moestl.Pp 636c4a5ef6eSThomas MoestlThe average number of kilobytes per transfer between the acquisition of 637c4a5ef6eSThomas Moestl.Va previous 638c4a5ef6eSThomas Moestland 639c4a5ef6eSThomas Moestl.Va current . 640c4a5ef6eSThomas Moestl.It DSM_KB_PER_TRANSFER_READ 641c4a5ef6eSThomas Moestltype: long double * 642c4a5ef6eSThomas Moestl.Pp 643c4a5ef6eSThomas MoestlThe average number of kilobytes per read transaction between the acquisition of 644c4a5ef6eSThomas Moestl.Va previous 645c4a5ef6eSThomas Moestland 646c4a5ef6eSThomas Moestl.Va current . 647c4a5ef6eSThomas Moestl.It DSM_KB_PER_TRANSFER_WRITE 648c4a5ef6eSThomas Moestltype: long double * 649c4a5ef6eSThomas Moestl.Pp 650c4a5ef6eSThomas MoestlThe average number of kilobytes per write transaction between the acquisition of 651c4a5ef6eSThomas Moestl.Va previous 652c4a5ef6eSThomas Moestland 653c4a5ef6eSThomas Moestl.Va current . 654c4a5ef6eSThomas Moestl.It DSM_TRANSFERS_PER_SECOND 655c4a5ef6eSThomas Moestltype: long double * 656c4a5ef6eSThomas Moestl.Pp 657c4a5ef6eSThomas MoestlThe average number of transfers per second between the acquisition of 658c4a5ef6eSThomas Moestl.Va previous 659c4a5ef6eSThomas Moestland 660c4a5ef6eSThomas Moestl.Va current . 661c4a5ef6eSThomas Moestl.It DSM_TRANSFERS_PER_SECOND_READ 662c4a5ef6eSThomas Moestltype: long double * 663c4a5ef6eSThomas Moestl.Pp 664c4a5ef6eSThomas MoestlThe average number of reads per second between the acquisition of 665c4a5ef6eSThomas Moestl.Va previous 666c4a5ef6eSThomas Moestland 667c4a5ef6eSThomas Moestl.Va current . 668c4a5ef6eSThomas Moestl.It DSM_TRANSFERS_PER_SECOND_WRITE 669c4a5ef6eSThomas Moestltype: long double * 670c4a5ef6eSThomas Moestl.Pp 671c4a5ef6eSThomas MoestlThe average number of writes per second between the acquisition of 672c4a5ef6eSThomas Moestl.Va previous 673c4a5ef6eSThomas Moestland 674c4a5ef6eSThomas Moestl.Va current . 675c4a5ef6eSThomas Moestl.It DSM_TRANSFERS_PER_SECOND_OTHER 676c4a5ef6eSThomas Moestltype: long double * 677c4a5ef6eSThomas Moestl.Pp 678c4a5ef6eSThomas MoestlThe average number of non-read, non-write transactions per second between 679c4a5ef6eSThomas Moestlthe acquisition of 680c4a5ef6eSThomas Moestl.Va previous 681c4a5ef6eSThomas Moestland 682c4a5ef6eSThomas Moestl.Va current . 683c4a5ef6eSThomas Moestl.It DSM_MB_PER_SECOND 684c4a5ef6eSThomas Moestltype: long double * 685c4a5ef6eSThomas Moestl.Pp 686c4a5ef6eSThomas MoestlThe average number of megabytes transferred per second between the 687c4a5ef6eSThomas Moestlacquisition of 688c4a5ef6eSThomas Moestl.Va previous 689c4a5ef6eSThomas Moestland 690c4a5ef6eSThomas Moestl.Va current . 691c4a5ef6eSThomas Moestl.It DSM_MB_PER_SECOND_READ 692c4a5ef6eSThomas Moestltype: long double * 693c4a5ef6eSThomas Moestl.Pp 694c4a5ef6eSThomas MoestlThe average number of megabytes read per second between the acquisition of 695c4a5ef6eSThomas Moestl.Va previous 696c4a5ef6eSThomas Moestland 697c4a5ef6eSThomas Moestl.Va current . 698c4a5ef6eSThomas Moestl.It DSM_MB_PER_SECOND_WRITE 699c4a5ef6eSThomas Moestltype: long double * 700c4a5ef6eSThomas Moestl.Pp 701c4a5ef6eSThomas MoestlThe average number of megabytes written per second between the acquisition of 702c4a5ef6eSThomas Moestl.Va previous 703c4a5ef6eSThomas Moestland 704c4a5ef6eSThomas Moestl.Va current . 705c4a5ef6eSThomas Moestl.It DSM_BLOCKS_PER_SECOND 706c4a5ef6eSThomas Moestltype: long double * 707c4a5ef6eSThomas Moestl.Pp 708c4a5ef6eSThomas MoestlThe average number of blocks transferred per second between the acquisition of 709c4a5ef6eSThomas Moestl.Va previous 710c4a5ef6eSThomas Moestland 711c4a5ef6eSThomas Moestl.Va current . 712c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 713c4a5ef6eSThomas MoestlIf no blocksize has been reported (i.e. the block size is 0), a default 714c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 715c4a5ef6eSThomas Moestl.It DSM_BLOCKS_PER_SECOND_READ 716c4a5ef6eSThomas Moestltype: long double * 717c4a5ef6eSThomas Moestl.Pp 718c4a5ef6eSThomas MoestlThe average number of blocks read per second between the acquisition of 719c4a5ef6eSThomas Moestl.Va previous 720c4a5ef6eSThomas Moestland 721c4a5ef6eSThomas Moestl.Va current . 722c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 723c4a5ef6eSThomas MoestlIf no blocksize has been reported (i.e. the block size is 0), a default 724c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 725c4a5ef6eSThomas Moestl.It DSM_BLOCKS_PER_SECOND_WRITE 726c4a5ef6eSThomas Moestltype: long double * 727c4a5ef6eSThomas Moestl.Pp 728c4a5ef6eSThomas MoestlThe average number of blocks written per second between the acquisition of 729c4a5ef6eSThomas Moestl.Va previous 730c4a5ef6eSThomas Moestland 731c4a5ef6eSThomas Moestl.Va current . 732c4a5ef6eSThomas MoestlThis number is in terms of the blocksize reported by the device. 733c4a5ef6eSThomas MoestlIf no blocksize has been reported (i.e. the block size is 0), a default 734c4a5ef6eSThomas Moestlblocksize of 512 bytes will be used in the calculation. 735c4a5ef6eSThomas Moestl.It DSM_MS_PER_TRANSACTION 736c4a5ef6eSThomas Moestltype: long double * 737c4a5ef6eSThomas Moestl.Pp 738c4a5ef6eSThomas MoestlThe average rate of transaction completion between the acquisition of 739c4a5ef6eSThomas Moestl.Va previous 740c4a5ef6eSThomas Moestland 741c4a5ef6eSThomas Moestl.Va current . 742c4a5ef6eSThomas MoestlNote that this isn't a true reflection of the average number of 743c4a5ef6eSThomas Moestlmilliseconds per transaction, but rather is the average rate of transaction 744c4a5ef6eSThomas Moestlcompletion. 745c4a5ef6eSThomas MoestlThe number is derived by dividing the time elapsed by the number of 746c4a5ef6eSThomas Moestltransactions completed. 747c4a5ef6eSThomas Moestl.It DSM_MS_PER_TRANSACTION_READ 748c4a5ef6eSThomas Moestltype: long double * 749c4a5ef6eSThomas Moestl.Pp 750c4a5ef6eSThomas MoestlThe average rate of read completions between the acquisition of 751c4a5ef6eSThomas Moestl.Va previous 752c4a5ef6eSThomas Moestland 753c4a5ef6eSThomas Moestl.Va current . 754c4a5ef6eSThomas MoestlAs above, this is not the true number of milliseconds per transaction, but 755c4a5ef6eSThomas Moestlrather the average rate of read transaction completion. 756c4a5ef6eSThomas Moestl.It DSM_MS_PER_TRANSACTION_WRITE 757c4a5ef6eSThomas Moestltype: long double * 758c4a5ef6eSThomas Moestl.Pp 759c4a5ef6eSThomas MoestlThe average rate of write transaction completion between the acquisition of 760c4a5ef6eSThomas Moestl.Va previous 761c4a5ef6eSThomas Moestland 762c4a5ef6eSThomas Moestl.Va current . 763c4a5ef6eSThomas MoestlAs above, this is not the true number of milliseconds per transaction, but 764c4a5ef6eSThomas Moestlrather the average rate of write transaction completion. 765884539f7SKenneth D. Merry.It DSM_SKIP 766884539f7SKenneth D. Merrytype: N/A 767884539f7SKenneth D. Merry.Pp 768884539f7SKenneth D. MerryIf you do not need a result from 769884539f7SKenneth D. Merry.Fn devstat_compute_statistics , 770884539f7SKenneth D. Merryjust put 771884539f7SKenneth D. Merry.Va DSM_SKIP 772884539f7SKenneth D. Merryas first (type) parameter and 773884539f7SKenneth D. Merry.Va NULL 774884539f7SKenneth D. Merryas second parameter. 775884539f7SKenneth D. MerryThis can be useful in scenarios where the statistics to be calculated 776884539f7SKenneth D. Merryare determined at run time. 777c4a5ef6eSThomas Moestl.El 778c4a5ef6eSThomas Moestl.Pp 779c4a5ef6eSThomas Moestl.Fn compute_stats 780c4a5ef6eSThomas Moestlis deprecated; use 781c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 782c4a5ef6eSThomas Moestlinstead. 783c4a5ef6eSThomas Moestl.Fn compute_stats 784c4a5ef6eSThomas Moestlprovides an easy way to obtain various device statistics. 785c4a5ef6eSThomas MoestlOnly two arguments are mandatory: 78628fb27baSJustin T. Gibbs.Va current 78728fb27baSJustin T. Gibbsand 78828fb27baSJustin T. Gibbs.Va etime . 789c4a5ef6eSThomas MoestlEvery other argument is optional. 790c4a5ef6eSThomas MoestlFor most applications, the user will want to supply both 79128fb27baSJustin T. Gibbs.Va current 79228fb27baSJustin T. Gibbsand 79328fb27baSJustin T. Gibbs.Va previous 79428fb27baSJustin T. Gibbsdevstat structures so that statistics may be calculated over a given period 795c4a5ef6eSThomas Moestlof time. 796c4a5ef6eSThomas MoestlIn some instances, for instance when calculating statistics since system boot, 797c4a5ef6eSThomas Moestlthe user may pass in a NULL pointer for the 79828fb27baSJustin T. Gibbs.Va previous 799c4a5ef6eSThomas Moestlargument. 800c4a5ef6eSThomas MoestlIn that case, 80128fb27baSJustin T. Gibbs.Fn compute_stats 80228fb27baSJustin T. Gibbswill use the total stats in the 80328fb27baSJustin T. Gibbs.Va current 80428fb27baSJustin T. Gibbsstructure to calculate statistics over 80528fb27baSJustin T. Gibbs.Va etime . 80628fb27baSJustin T. GibbsThe various statistics that may be calculated by 80728fb27baSJustin T. Gibbs.Fn compute_stats 80828fb27baSJustin T. Gibbsshould be mostly explained by the function declaration itself, but for 80928fb27baSJustin T. Gibbscompleteness here is a list of variable names and the statistics that will 81028fb27baSJustin T. Gibbsbe put in them: 81128fb27baSJustin T. Gibbs.Bl -tag -width transfers_per_second 81228fb27baSJustin T. Gibbs.It total_bytes 81328fb27baSJustin T. GibbsThis is the total number of bytes transferred on the given device, both 81428fb27baSJustin T. Gibbsreads and writes, between the acquisition of 81528fb27baSJustin T. Gibbs.Va previous 81628fb27baSJustin T. Gibbsand the acquisition of 81728fb27baSJustin T. Gibbs.Va current . 81828fb27baSJustin T. GibbsIf 81928fb27baSJustin T. Gibbs.Va previous 82028fb27baSJustin T. Gibbsis NULL, the result will be the total reads and writes given in 82128fb27baSJustin T. Gibbs.Va current . 82228fb27baSJustin T. Gibbs.It total_transfers 82328fb27baSJustin T. GibbsThis is the total number of transfers completed between the 82428fb27baSJustin T. Gibbsacquisition of 82528fb27baSJustin T. Gibbs.Va previous 82628fb27baSJustin T. Gibbsand the acquisition of 82728fb27baSJustin T. Gibbs.Va current . 82828fb27baSJustin T. GibbsIf 82928fb27baSJustin T. Gibbs.Va previous 83028fb27baSJustin T. Gibbsis NULL, the result will be the total number of transactions listed in 83128fb27baSJustin T. Gibbs.Va current . 83228fb27baSJustin T. Gibbs.It total_blocks 83328fb27baSJustin T. GibbsThis is basically 83428fb27baSJustin T. Gibbs.Va total_bytes 835c4a5ef6eSThomas Moestldivided by the device blocksize. 836c4a5ef6eSThomas MoestlIf the device blocksize is listed as 83728fb27baSJustin T. Gibbs.Sq 0 , 83828fb27baSJustin T. Gibbsthe device blocksize will default to 512 bytes. 83928fb27baSJustin T. Gibbs.It kb_per_transfer 84028fb27baSJustin T. GibbsThis is the average number of kilobytes per transfer during the measurement 84128fb27baSJustin T. Gibbsperiod. 84228fb27baSJustin T. Gibbs.It transfers_per_second 84328fb27baSJustin T. GibbsThis is the average number of transfers per second. 84428fb27baSJustin T. Gibbs.It mb_per_second 84528fb27baSJustin T. GibbsThis is average megabytes per second. 84628fb27baSJustin T. Gibbs.It blocks_per_second 847c4a5ef6eSThomas MoestlThis is average blocks per second. 848c4a5ef6eSThomas MoestlIf the device blocksize is 84928fb27baSJustin T. Gibbs.Sq 0 , 85028fb27baSJustin T. Gibbsa default blocksize of 512 bytes will be used instead. 85128fb27baSJustin T. Gibbs.It ms_per_transaction 8525db9ad2cSDavid E. O'BrienThe average number of milliseconds per transaction. 85328fb27baSJustin T. Gibbs.El 85428fb27baSJustin T. Gibbs.Pp 855c4a5ef6eSThomas Moestl.Fn devstat_compute_etime 85628fb27baSJustin T. Gibbsprovides an easy way to find the difference in seconds between two 85728fb27baSJustin T. Gibbs.Va timeval 858c4a5ef6eSThomas Moestlstructures. 859c4a5ef6eSThomas MoestlThis is most commonly used in conjunction with the time recorded by the 860c4a5ef6eSThomas Moestl.Fn devstat_getdevs 86128fb27baSJustin T. Gibbsfunction (in struct 86228fb27baSJustin T. Gibbs.Va statinfo ) 86328fb27baSJustin T. Gibbseach time it fetches the current 86428fb27baSJustin T. Gibbs.Nm 86528fb27baSJustin T. Gibbslist. 866c4a5ef6eSThomas Moestl.Pp 867c4a5ef6eSThomas Moestl.Fn compute_etime 868c4a5ef6eSThomas Moestlis the old name of 869c4a5ef6eSThomas Moestl.Fn devstat_compute_etime , 870c4a5ef6eSThomas Moestland is deprecated. 87128fb27baSJustin T. Gibbs.Sh RETURN VALUES 872c4a5ef6eSThomas Moestl.Fn devstat_getnumdevs , 873c4a5ef6eSThomas Moestl.Fn devstat_getgeneration , 87428fb27baSJustin T. Gibbsand 875c4a5ef6eSThomas Moestl.Fn devstat_getversion 87628fb27baSJustin T. Gibbsreturn the indicated \fBsysctl\fR variable, or -1 if there is an error 87728fb27baSJustin T. Gibbsfetching the variable. 87828fb27baSJustin T. Gibbs.Pp 879c4a5ef6eSThomas Moestl.Fn devstat_checkversion 88028fb27baSJustin T. Gibbsreturns 0 if the kernel and userland 8813b8ecdbbSRuslan Ermilov.Nm 882c4a5ef6eSThomas Moestlversions match. 883c4a5ef6eSThomas MoestlIf they do not match, it returns -1. 88428fb27baSJustin T. Gibbs.Pp 885c4a5ef6eSThomas Moestl.Fn devstat_getdevs 88628fb27baSJustin T. Gibbsand 887c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 88828fb27baSJustin T. Gibbsreturn -1 in case of an error, 0 if there is no error and 1 if the device 889c4a5ef6eSThomas Moestllist or selected devices have changed. 890c4a5ef6eSThomas MoestlA return value of 1 from 891c4a5ef6eSThomas Moestl.Fn devstat_getdevs 89228fb27baSJustin T. Gibbsis usually a hint to re-run 893c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 89428fb27baSJustin T. Gibbsbecause the device list has changed. 89528fb27baSJustin T. Gibbs.Pp 896c4a5ef6eSThomas Moestl.Fn devstat_buildmatch 89728fb27baSJustin T. Gibbsreturns -1 for error, and 0 if there is no error. 89828fb27baSJustin T. Gibbs.Pp 89928fb27baSJustin T. Gibbs.Fn compute_stats 90028fb27baSJustin T. Gibbsreturns -1 for error, and 0 for success. 90128fb27baSJustin T. Gibbs.Pp 902c4a5ef6eSThomas Moestl.Fn devstat_compute_etime 90328fb27baSJustin T. Gibbsreturns the computed elapsed time. 90428fb27baSJustin T. Gibbs.Pp 905c4a5ef6eSThomas Moestl.Fn devstat_compute_statistics 906c4a5ef6eSThomas Moestlreturns -1 for error, and 0 for success. 907c4a5ef6eSThomas Moestl.Pp 90828fb27baSJustin T. GibbsIf an error is returned from one of the 90928fb27baSJustin T. Gibbs.Nm 91028fb27baSJustin T. Gibbslibrary functions, the reason for the error is generally printed in 91128fb27baSJustin T. Gibbsthe global string 91228fb27baSJustin T. Gibbs.Va devstat_errbuf 91328fb27baSJustin T. Gibbswhich is 91428fb27baSJustin T. Gibbs.Dv DEVSTAT_ERRBUF_SIZE 91528fb27baSJustin T. Gibbscharacters long. 91628fb27baSJustin T. Gibbs.Sh SEE ALSO 91728fb27baSJustin T. Gibbs.Xr systat 1 , 918c4a5ef6eSThomas Moestl.Xr kvm 3 , 919c4a5ef6eSThomas Moestl.Xr sysctl 3 , 92028fb27baSJustin T. Gibbs.Xr iostat 8 , 92128fb27baSJustin T. Gibbs.Xr rpc.rstatd 8 , 922265c01dfSRuslan Ermilov.Xr sysctl 8 , 92328fb27baSJustin T. Gibbs.Xr vmstat 8 , 92428fb27baSJustin T. Gibbs.Xr devstat 9 92528fb27baSJustin T. Gibbs.Sh HISTORY 92628fb27baSJustin T. GibbsThe 92728fb27baSJustin T. Gibbs.Nm 92828fb27baSJustin T. Gibbsstatistics system first appeared in 92928fb27baSJustin T. Gibbs.Fx 3.0 . 930c4a5ef6eSThomas MoestlThe new interface (the functions prefixed with devstat_) first appeared in 931c4a5ef6eSThomas Moestl.Fx 5.0 . 93228fb27baSJustin T. Gibbs.Sh AUTHORS 933d0353b83SRuslan Ermilov.An Kenneth Merry Aq ken@FreeBSD.org 93428fb27baSJustin T. Gibbs.Sh BUGS 93528fb27baSJustin T. GibbsThere should probably be an interface to de-allocate memory allocated by 936c4a5ef6eSThomas Moestl.Fn devstat_getdevs , 937c4a5ef6eSThomas Moestl.Fn devstat_selectdevs , 93828fb27baSJustin T. Gibbsand 939c4a5ef6eSThomas Moestl.Fn devstat_buildmatch . 94028fb27baSJustin T. Gibbs.Pp 941c4a5ef6eSThomas Moestl.Fn devstat_selectdevs 94228fb27baSJustin T. Gibbsshould probably not select more than 94328fb27baSJustin T. Gibbs.Va maxshowdevs 94428fb27baSJustin T. Gibbsdevices in 94528fb27baSJustin T. Gibbs.Dq top 94628fb27baSJustin T. Gibbsmode when no devices have been selected previously. 94728fb27baSJustin T. Gibbs.Pp 94828fb27baSJustin T. GibbsThere should probably be functions to perform the statistics buffer 94928fb27baSJustin T. Gibbsswapping that goes on in most of the clients of this library. 95028fb27baSJustin T. Gibbs.Pp 95128fb27baSJustin T. GibbsThe 95228fb27baSJustin T. Gibbs.Va statinfo 95328fb27baSJustin T. Gibbsand 95428fb27baSJustin T. Gibbs.Va devinfo 95528fb27baSJustin T. Gibbsstructures should probably be cleaned up and thought out a little more. 956