Print this page
749 "/usr/bin/kstat" should be rewritten in C
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Brendan Gregg <brendan.gregg@joyent.com>
kstat
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1m/kstat.1m
+++ new/usr/src/man/man1m/kstat.1m
1 1 '\" te
2 2 .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved
3 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 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 5 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 -.TH KSTAT 1M "Mar 23, 2009"
6 +.TH KSTAT 1M "Nov 22, 2012"
7 7 .SH NAME
8 8 kstat \- display kernel statistics
9 9 .SH SYNOPSIS
10 10 .LP
11 11 .nf
12 -\fBkstat\fR [\fB-lpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR] [\fB-m\fR \fImodule\fR]
12 +\fBkstat\fR [\fB-Cjlpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR] [\fB-m\fR \fImodule\fR]
13 13 [\fB-i\fR \fIinstance\fR] [\fB-n\fR \fIname\fR] [\fB-s\fR \fIstatistic\fR]
14 14 [interval [count]]
15 15 .fi
16 16
17 17 .LP
18 18 .nf
19 -\fBkstat\fR [\fB-lpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR]
19 +\fBkstat\fR [\fB-Cjlpq\fR] [\fB-T\fR u | d ] [\fB-c\fR \fIclass\fR]
20 20 [\fImodule\fR:\fIinstance\fR:\fIname\fR:\fIstatistic\fR]...
21 21 [interval [count]]
22 22 .fi
23 23
24 24 .SH DESCRIPTION
25 25 .sp
26 26 .LP
27 27 The \fBkstat\fR utility examines the available kernel statistics, or kstats, on
28 28 the system and reports those statistics which match the criteria specified on
29 29 the command line. Each matching statistic is printed with its module, instance,
30 30 and name fields, as well as its actual value.
31 31 .sp
32 32 .LP
33 33 Kernel statistics may be published by various kernel subsystems, such as
34 34 drivers or loadable modules; each kstat has a module field that denotes its
35 35 publisher. Since each module might have countable entities (such as multiple
36 36 disks associated with the \fBsd\fR(7D) driver) for which it wishes to report
37 37 statistics, the kstat also has an instance field to index the statistics for
38 38 each entity; kstat instances are numbered starting from zero. Finally, the
39 39 kstat is given a name unique within its module.
40 40 .sp
41 41 .LP
42 42 Each kstat may be a special kstat type, an array of name-value pairs, or raw
43 43 data. In the name-value case, each reported value is given a label, which we
44 44 refer to as the statistic. Known raw and special kstats are given statistic
45 45 labels for each of their values by \fBkstat\fR; thus, all published values can
46 46 be referenced as \fImodule\fR:\fIinstance\fR:\fIname\fR:\fIstatistic\fR.
47 47 .sp
48 48 .LP
49 49 When invoked without any module operands or options, kstat will match all
50 50 defined statistics on the system. Example invocations are provided below. All
51 51 times are displayed as fractional seconds since system boot.
↓ open down ↓ |
22 lines elided |
↑ open up ↑ |
52 52 .SH OPTIONS
53 53 .sp
54 54 .LP
55 55 The tests specified by the following options are logically ANDed, and all
56 56 matching kstats will be selected. A regular expression containing shell
57 57 metacharacters must be protected from the shell by enclosing it with the
58 58 appropriate quotes.
59 59 .sp
60 60 .LP
61 61 The argument for the \fB-c\fR, \fB-i\fR, \fB-m\fR, \fB-n\fR, and \fB-s\fR
62 -options may be specified as a shell glob pattern, or a Perl regular expression
63 -enclosed in '/' characters.
62 +options may be specified as a shell glob pattern.
63 +.sp
64 +.ne 2
65 +.na
66 +\fB\fB-C\fR\fR
67 +.ad
68 +.RS 16n
69 +Displays output in parseable format with a colon as separator.
70 +.RE
71 +
64 72 .sp
65 73 .ne 2
66 74 .na
67 75 \fB\fB-c\fR \fIclass\fR\fR
68 76 .ad
69 77 .RS 16n
70 78 Displays only kstats that match the specified class. \fIclass\fR is a
71 79 kernel-defined string which classifies the "type" of the kstat.
72 80 .RE
73 81
74 82 .sp
75 83 .ne 2
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
76 84 .na
77 85 \fB\fB-i\fR \fIinstance\fR\fR
78 86 .ad
79 87 .RS 16n
80 88 Displays only kstats that match the specified instance.
81 89 .RE
82 90
83 91 .sp
84 92 .ne 2
85 93 .na
94 +\fB\fB-j\fR\fR
95 +.ad
96 +.RS 16n
97 +Displays output in JSON format.
98 +.RE
99 +
100 +.sp
101 +.ne 2
102 +.na
86 103 \fB\fB-l\fR\fR
87 104 .ad
88 105 .RS 16n
89 106 Lists matching kstat names without displaying values.
90 107 .RE
91 108
92 109 .sp
93 110 .ne 2
94 111 .na
95 112 \fB\fB-m\fR \fImodule\fR\fR
96 113 .ad
97 114 .RS 16n
98 115 Displays only kstats that match the specified module.
99 116 .RE
100 117
101 118 .sp
102 119 .ne 2
103 120 .na
104 121 \fB\fB-n\fR \fIname\fR\fR
105 122 .ad
106 123 .RS 16n
107 124 Displays only kstats that match the specified name.
108 125 .RE
109 126
110 127 .sp
111 128 .ne 2
112 129 .na
113 130 \fB\fB-p\fR\fR
114 131 .ad
115 132 .RS 16n
116 133 Displays output in parseable format. All example output in this document is
117 134 given in this format. If this option is not specified, \fBkstat\fR produces
118 135 output in a human-readable, table format.
119 136 .RE
120 137
121 138 .sp
122 139 .ne 2
123 140 .na
124 141 \fB\fB-q\fR\fR
125 142 .ad
126 143 .RS 16n
127 144 Displays no output, but return appropriate exit status for matches against
128 145 given criteria.
129 146 .RE
130 147
131 148 .sp
132 149 .ne 2
133 150 .na
134 151 \fB\fB-s\fR \fIstatistic\fR\fR
135 152 .ad
136 153 .RS 16n
137 154 Displays only kstats that match the specified statistic.
138 155 .RE
139 156
140 157 .sp
141 158 .ne 2
142 159 .na
143 160 \fB\fB-T\fR d | u\fR
144 161 .ad
145 162 .RS 16n
146 163 Displays a time stamp before each statistics block, either in \fBdate\fR(1)
147 164 format (\fBd\fR) or as an alphanumeric representation of the value returned by
148 165 \fBtime\fR(2) (\fBu\fR).
149 166 .RE
150 167
151 168 .SH OPERANDS
152 169 .sp
153 170 .LP
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
154 171 The following operands are supported:
155 172 .sp
156 173 .ne 2
157 174 .na
158 175 \fB\fImodule\fR:\fIinstance\fR:\fIname\fR:\fIstatistic\fR\fR
159 176 .ad
160 177 .sp .6
161 178 .RS 4n
162 179 Alternate method of specifying module, instance, name, and statistic as
163 180 described above. Each of the module, instance, name, or statistic specifiers
164 -may be a shell glob pattern or a Perl regular expression enclosed by '/'
165 -characters. It is possible to use both specifier types within a single operand.
181 +may be a shell glob pattern.
182 +It is possible to use both specifier types within a single operand.
166 183 Leaving a specifier empty is equivalent to using the '*' glob pattern for that
167 184 specifier.
168 185 .RE
169 186
170 187 .sp
171 188 .ne 2
172 189 .na
173 190 \fB\fIinterval\fR\fR
174 191 .ad
175 192 .sp .6
176 193 .RS 4n
177 194 The number of seconds between reports.
178 195 .RE
179 196
180 197 .sp
181 198 .ne 2
182 199 .na
183 200 \fB\fIcount\fR\fR
184 201 .ad
185 202 .sp .6
186 203 .RS 4n
187 204 The number of reports to be printed.
188 205 .RE
189 206
190 207 .SH EXAMPLES
191 208 .sp
192 209 .LP
193 210 In the following examples, all the command lines in a block produce the same
194 211 output, as shown immediately below. The exact statistics and values will of
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
195 212 course vary from machine to machine.
196 213 .LP
197 214 \fBExample 1 \fRUsing the \fBkstat\fR Command
198 215 .sp
199 216 .in +2
200 217 .nf
201 218 example$ \fBkstat -p -m unix -i 0 -n system_misc -s 'avenrun*'\fR
202 219 example$ \fBkstat -p -s 'avenrun*'\fR
203 220 example$ \fBkstat -p 'unix:0:system_misc:avenrun*'\fR
204 221 example$ \fBkstat -p ':::avenrun*'\fR
205 -example$ \fBkstat -p ':::/^avenrun_\ed+min$/'\fR
222 +example$ \fBkstat -p ':::avenrun*min$'\fR
206 223
207 224 unix:0:system_misc:avenrun_15min 3
208 225 unix:0:system_misc:avenrun_1min 4
209 226 unix:0:system_misc:avenrun_5min 2
210 227 .fi
211 228 .in -2
212 229 .sp
213 230
214 231 .LP
215 232 \fBExample 2 \fRUsing the \fBkstat\fR Command
216 233 .sp
217 234 .in +2
218 235 .nf
219 236 example$ \fBkstat -p -m cpu_stat -s 'intr*'\fR
220 -example$ \fBkstat -p cpu_stat:::/^intr/\fR
237 +example$ \fBkstat -p 'cpu_stat:::intr*'\fR
221 238
222 239 cpu_stat:0:cpu_stat0:intr 29682330
223 240 cpu_stat:0:cpu_stat0:intrblk 87
224 241 cpu_stat:0:cpu_stat0:intrthread 15054222
225 242 cpu_stat:1:cpu_stat1:intr 426073
226 243 cpu_stat:1:cpu_stat1:intrblk 51
227 244 cpu_stat:1:cpu_stat1:intrthread 289668
228 245 cpu_stat:2:cpu_stat2:intr 134160
229 246 cpu_stat:2:cpu_stat2:intrblk 0
230 247 cpu_stat:2:cpu_stat2:intrthread 131
231 248 cpu_stat:3:cpu_stat3:intr 196566
232 249 cpu_stat:3:cpu_stat3:intrblk 30
233 250 cpu_stat:3:cpu_stat3:intrthread 59626
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
234 251 .fi
235 252 .in -2
236 253 .sp
237 254
238 255 .LP
239 256 \fBExample 3 \fRUsing the \fBkstat\fR Command
240 257 .sp
241 258 .in +2
242 259 .nf
243 260 example$ \fBkstat -p :::state ':::avenrun*'\fR
244 -example$ \fBkstat -p :::state :::/^avenrun/\fR
245 261
246 262 cpu_info:0:cpu_info0:state on-line
247 263 cpu_info:1:cpu_info1:state on-line
248 264 cpu_info:2:cpu_info2:state on-line
249 265 cpu_info:3:cpu_info3:state on-line
250 266 unix:0:system_misc:avenrun_15min 4
251 267 unix:0:system_misc:avenrun_1min 10
252 268 unix:0:system_misc:avenrun_5min 3
253 269 .fi
254 270 .in -2
255 271 .sp
256 272
257 273 .LP
258 274 \fBExample 4 \fRUsing the \fBkstat\fR Command
259 275 .sp
260 276 .in +2
261 277 .nf
262 278 example$ \fBkstat -p 'unix:0:system_misc:avenrun*' 1 3\fR
263 279 unix:0:system_misc:avenrun_15min 15
264 280 unix:0:system_misc:avenrun_1min 11
265 281 unix:0:system_misc:avenrun_5min 21
266 282
267 283 unix:0:system_misc:avenrun_15min 15
268 284 unix:0:system_misc:avenrun_1min 11
269 285 unix:0:system_misc:avenrun_5min 21
270 286
271 287 unix:0:system_misc:avenrun_15min 15
272 288 unix:0:system_misc:avenrun_1min 11
273 289 unix:0:system_misc:avenrun_5min 21
274 290 .fi
275 291 .in -2
276 292 .sp
277 293
278 294 .LP
279 295 \fBExample 5 \fRUsing the \fBkstat\fR Command
280 296 .sp
281 297 .in +2
282 298 .nf
283 299 example$ \fBkstat -p -T d 'unix:0:system_misc:avenrun*' 5 2\fR
284 300 Thu Jul 22 19:39:50 1999
285 301 unix:0:system_misc:avenrun_15min 12
286 302 unix:0:system_misc:avenrun_1min 0
287 303 unix:0:system_misc:avenrun_5min 11
288 304
289 305 Thu Jul 22 19:39:55 1999
290 306 unix:0:system_misc:avenrun_15min 12
291 307 unix:0:system_misc:avenrun_1min 0
292 308 unix:0:system_misc:avenrun_5min 11
293 309 .fi
294 310 .in -2
295 311 .sp
296 312
297 313 .LP
298 314 \fBExample 6 \fRUsing the \fBkstat\fR Command
299 315 .sp
300 316 .in +2
301 317 .nf
302 318 example$ \fBkstat -p -T u 'unix:0:system_misc:avenrun*'\fR
303 319 932668656
304 320 unix:0:system_misc:avenrun_15min 14
305 321 unix:0:system_misc:avenrun_1min 5
306 322 unix:0:system_misc:avenrun_5min 18
307 323 .fi
308 324 .in -2
309 325 .sp
310 326
311 327 .SH EXIT STATUS
312 328 .sp
313 329 .LP
314 330 The following exit values are returned:
315 331 .sp
316 332 .ne 2
317 333 .na
318 334 \fB\fB0\fR\fR
319 335 .ad
320 336 .RS 5n
321 337 One or more statistics were matched.
322 338 .RE
323 339
324 340 .sp
325 341 .ne 2
326 342 .na
327 343 \fB\fB1\fR\fR
328 344 .ad
329 345 .RS 5n
330 346 No statistics were matched.
331 347 .RE
332 348
333 349 .sp
334 350 .ne 2
335 351 .na
336 352 \fB\fB2\fR\fR
337 353 .ad
338 354 .RS 5n
339 355 Invalid command line options were specified.
340 356 .RE
341 357
342 358 .sp
343 359 .ne 2
344 360 .na
345 361 \fB\fB3\fR\fR
346 362 .ad
347 363 .RS 5n
348 364 A fatal error occurred.
349 365 .RE
350 366
351 367 .SH FILES
352 368 .sp
353 369 .ne 2
354 370 .na
355 371 \fB\fB/dev/kstat\fR\fR
356 372 .ad
357 373 .RS 14n
358 374 kernel statistics driver
359 375 .RE
↓ open down ↓ |
105 lines elided |
↑ open up ↑ |
360 376
361 377 .SH SEE ALSO
362 378 .sp
363 379 .LP
364 380 \fBdate\fR(1), \fBsh\fR(1), \fBtime\fR(2), \fBgmatch\fR(3GEN),
365 381 \fBkstat\fR(3KSTAT), \fBattributes\fR(5), \fBkstat\fR(7D), \fBsd\fR(7D),
366 382 \fBkstat\fR(9S)
367 383 .SH NOTES
368 384 .sp
369 385 .LP
370 -If the pattern argument contains glob or Perl RE metacharacters which are also
386 +If the pattern argument contains glob metacharacters which are also
371 387 shell metacharacters, it will be necessary to enclose the pattern with
372 388 appropriate shell quotes.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX