Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man8 / kstat.8
blobf14a3e42bc93082910e1d1147e4e24d2deb8a45f
1 '\" te
2 .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
4 .\"  See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with
5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH KSTAT 8 "April 9, 2016"
7 .SH NAME
8 kstat \- display kernel statistics
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBkstat\fR [\fB-Cjlpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR] [\fB-m\fR \fImodule\fR]
13      [\fB-i\fR \fIinstance\fR] [\fB-n\fR \fIname\fR] [\fB-s\fR \fIstatistic\fR]
14      [interval [count]]
15 .fi
17 .LP
18 .nf
19 \fBkstat\fR [\fB-Cjlpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR]
20      [\fImodule\fR[:\fIinstance\fR[:\fIname\fR[:\fIstatistic\fR]]]]...
21      [interval [count]]
22 .fi
24 .SH DESCRIPTION
25 .LP
26 The \fBkstat\fR utility examines the available kernel statistics, or kstats, on
27 the system and reports those statistics which match the criteria specified on
28 the command line. Each matching statistic is printed with its module, instance,
29 and name fields, as well as its actual value.
30 .sp
31 .LP
32 Kernel statistics may be published by various kernel subsystems, such as
33 drivers or loadable modules; each kstat has a module field that denotes its
34 publisher. Since each module might have countable entities (such as multiple
35 disks associated with the \fBsd\fR(7D) driver) for which it wishes to report
36 statistics, the kstat also has an instance field to index the statistics for
37 each entity; kstat instances are numbered starting from zero. Finally, the
38 kstat is given a name unique within its module.
39 .sp
40 .LP
41 Each kstat may be a special kstat type, an array of name-value pairs, or raw
42 data. In the name-value case, each reported value is given a label, which we
43 refer to as the statistic. Known raw and special kstats are given statistic
44 labels for each of their values by \fBkstat\fR; thus, all published values can
45 be referenced as \fImodule\fR:\fIinstance\fR:\fIname\fR:\fIstatistic\fR.
46 .sp
47 .LP
48 When invoked without any module operands or options, kstat will match all
49 defined statistics on the system. Example invocations are provided below. All
50 times are displayed as fractional seconds since system boot.
51 .SH OPTIONS
52 .LP
53 The tests specified by the following options are logically ANDed, and all
54 matching kstats will be selected. A regular expression containing shell
55 metacharacters must be protected from the shell by enclosing it with the
56 appropriate quotes.
57 .sp
58 .LP
59 The argument for the \fB-c\fR, \fB-i\fR, \fB-m\fR, \fB-n\fR, and \fB-s\fR
60 options may be specified as a shell glob pattern, or a regular expression
61 enclosed in '/' characters.
62 .sp
63 .ne 2
64 .na
65 \fB\fB-C\fR\fR
66 .ad
67 .RS 16n
68 Displays output in parsable format with a colon as separator.
69 .RE
71 .sp
72 .ne 2
73 .na
74 \fB\fB-c\fR \fIclass\fR\fR
75 .ad
76 .RS 16n
77 Displays only kstats that match the specified class. \fIclass\fR is a
78 kernel-defined string which classifies the "type" of the kstat.
79 .RE
81 .sp
82 .ne 2
83 .na
84 \fB\fB-i\fR \fIinstance\fR\fR
85 .ad
86 .RS 16n
87 Displays only kstats that match the specified instance.
88 .RE
90 .sp
91 .ne 2
92 .na
93 \fB\fB-j\fR\fR
94 .ad
95 .RS 16n
96 Displays output in JSON format.
97 .RE
99 .sp
100 .ne 2
102 \fB\fB-l\fR\fR
104 .RS 16n
105 Lists matching kstat names without displaying values.
109 .ne 2
111 \fB\fB-m\fR \fImodule\fR\fR
113 .RS 16n
114 Displays only kstats that match the specified module.
118 .ne 2
120 \fB\fB-n\fR \fIname\fR\fR
122 .RS 16n
123 Displays only kstats that match the specified name.
127 .ne 2
129 \fB\fB-p\fR\fR
131 .RS 16n
132 Displays output in parsable format. All example output in this document is
133 given in this format. If this option is not specified, \fBkstat\fR produces
134 output in a human-readable, table format.
138 .ne 2
140 \fB\fB-q\fR\fR
142 .RS 16n
143 Displays no output, but return appropriate exit status for matches against
144 given criteria.
148 .ne 2
150 \fB\fB-s\fR \fIstatistic\fR\fR
152 .RS 16n
153 Displays only kstats that match the specified statistic.
157 .ne 2
159 \fB\fB-T\fR d | u\fR
161 .RS 16n
162 Displays a time stamp before each statistics block, either in \fBdate\fR(1)
163 format (\fBd\fR) or as an alphanumeric representation of the value returned by
164 \fBtime\fR(2) (\fBu\fR).
167 .SH OPERANDS
169 The following operands are supported:
171 .ne 2
173 \fB\fImodule\fR:\fIinstance\fR:\fIname\fR:\fIstatistic\fR\fR
175 .sp .6
176 .RS 4n
177 Alternate method of specifying module, instance, name, and statistic as
178 described above. Each of the module, instance, name, or statistic specifiers
179 may be a shell glob pattern or a regular expression enclosed by '/'
180 characters. It is possible to use both specifier types within a single operand.
181 Leaving a specifier empty is equivalent to using the '*' glob pattern for that
182 specifier.
186 .ne 2
188 \fB\fIinterval\fR\fR
190 .sp .6
191 .RS 4n
192 The number of seconds between reports.
196 .ne 2
198 \fB\fIcount\fR\fR
200 .sp .6
201 .RS 4n
202 The number of reports to be printed.
205 .SH EXAMPLES
207 In the following examples, all the command lines in a block produce the same
208 output, as shown immediately below. The exact statistics and values will of
209 course vary from machine to machine.
211 \fBExample 1 \fRUsing the \fBkstat\fR Command
213 .in +2
215 example$ \fBkstat -p -m unix -i 0 -n system_misc -s 'avenrun*'\fR
216 example$ \fBkstat -p -s 'avenrun*'\fR
217 example$ \fBkstat -p 'unix:0:system_misc:avenrun*'\fR
218 example$ \fBkstat -p ':::avenrun*'\fR
219 example$ \fBkstat -p ':::/^avenrun_[0-9]+min$/'\fR
221 unix:0:system_misc:avenrun_15min        3
222 unix:0:system_misc:avenrun_1min 4
223 unix:0:system_misc:avenrun_5min 2
225 .in -2
229 \fBExample 2 \fRUsing the \fBkstat\fR Command
231 .in +2
233 example$ \fBkstat -p -m cpu_stat -s 'intr*'\fR
234 example$ \fBkstat -p cpu_stat:::/^intr/\fR
236 cpu_stat:0:cpu_stat0:intr       29682330
237 cpu_stat:0:cpu_stat0:intrblk    87
238 cpu_stat:0:cpu_stat0:intrthread 15054222
239 cpu_stat:1:cpu_stat1:intr       426073
240 cpu_stat:1:cpu_stat1:intrblk    51
241 cpu_stat:1:cpu_stat1:intrthread 289668
242 cpu_stat:2:cpu_stat2:intr       134160
243 cpu_stat:2:cpu_stat2:intrblk    0
244 cpu_stat:2:cpu_stat2:intrthread 131
245 cpu_stat:3:cpu_stat3:intr       196566
246 cpu_stat:3:cpu_stat3:intrblk    30
247 cpu_stat:3:cpu_stat3:intrthread 59626
249 .in -2
253 \fBExample 3 \fRUsing the \fBkstat\fR Command
255 .in +2
257 example$ \fBkstat -p :::state ':::avenrun*'\fR
258 example$ \fBkstat -p :::state :::/^avenrun/\fR
260 cpu_info:0:cpu_info0:state      on-line
261 cpu_info:1:cpu_info1:state      on-line
262 cpu_info:2:cpu_info2:state      on-line
263 cpu_info:3:cpu_info3:state      on-line
264 unix:0:system_misc:avenrun_15min        4
265 unix:0:system_misc:avenrun_1min 10
266 unix:0:system_misc:avenrun_5min 3
268 .in -2
272 \fBExample 4 \fRUsing the \fBkstat\fR Command
274 .in +2
276 example$ \fBkstat -p 'unix:0:system_misc:avenrun*' 1 3\fR
277 unix:0:system_misc:avenrun_15min        15
278 unix:0:system_misc:avenrun_1min 11
279 unix:0:system_misc:avenrun_5min 21
281 unix:0:system_misc:avenrun_15min        15
282 unix:0:system_misc:avenrun_1min 11
283 unix:0:system_misc:avenrun_5min 21
285 unix:0:system_misc:avenrun_15min        15
286 unix:0:system_misc:avenrun_1min 11
287 unix:0:system_misc:avenrun_5min 21
289 .in -2
293 \fBExample 5 \fRUsing the \fBkstat\fR Command
295 .in +2
297 example$ \fBkstat -p -T d 'unix:0:system_misc:avenrun*' 5 2\fR
298 Thu Jul 22 19:39:50 1999
299 unix:0:system_misc:avenrun_15min        12
300 unix:0:system_misc:avenrun_1min 0
301 unix:0:system_misc:avenrun_5min 11
303 Thu Jul 22 19:39:55 1999
304 unix:0:system_misc:avenrun_15min        12
305 unix:0:system_misc:avenrun_1min 0
306 unix:0:system_misc:avenrun_5min 11
308 .in -2
312 \fBExample 6 \fRUsing the \fBkstat\fR Command
314 .in +2
316 example$ \fBkstat -p -T u 'unix:0:system_misc:avenrun*'\fR
317 932668656
318 unix:0:system_misc:avenrun_15min        14
319 unix:0:system_misc:avenrun_1min 5
320 unix:0:system_misc:avenrun_5min 18
322 .in -2
325 .SH EXIT STATUS
327 The following exit values are returned:
329 .ne 2
331 \fB\fB0\fR\fR
333 .RS 5n
334 One or more statistics were matched.
338 .ne 2
340 \fB\fB1\fR\fR
342 .RS 5n
343 No statistics were matched.
347 .ne 2
349 \fB\fB2\fR\fR
351 .RS 5n
352 Invalid command line options were specified.
356 .ne 2
358 \fB\fB3\fR\fR
360 .RS 5n
361 A fatal error occurred.
364 .SH FILES
365 .ne 2
367 \fB\fB/dev/kstat\fR\fR
369 .RS 14n
370 kernel statistics driver
373 .SH SEE ALSO
375 \fBdate\fR(1), \fBsh\fR(1), \fBtime\fR(2), \fBgmatch\fR(3GEN),
376 \fBkstat\fR(3KSTAT), \fBattributes\fR(5), \fBregex\fR(5), \fBkstat\fR(7D),
377 \fBsd\fR(7D), \fBkstat\fR(9S)
378 .SH NOTES
380 If the pattern argument contains glob or RE metacharacters which are also
381 shell metacharacters, it will be necessary to enclose the pattern with
382 appropriate shell quotes.