1kstat(1M) System Administration Commands kstat(1M)
2
3
4
6 kstat - display kernel statistics
7
9 kstat [-lpq] [-T u | d ] [-c class] [-m module]
10 [-i instance] [-n name] [-s statistic]
11 [interval [count]]
12
13
14 kstat [-lpq] [-T u | d ] [-c class]
15 [module:instance:name:statistic]...
16 [interval [count]]
17
18
20 The kstat utility examines the available kernel statistics, or kstats,
21 on the system and reports those statistics which match the criteria
22 specified on the command line. Each matching statistic is printed with
23 its module, instance, and name fields, as well as its actual value.
24
25
26 Kernel statistics may be published by various kernel subsystems, such
27 as drivers or loadable modules; each kstat has a module field that
28 denotes its publisher. Since each module might have countable entities
29 (such as multiple disks associated with the sd(7D) driver) for which it
30 wishes to report statistics, the kstat also has an instance field to
31 index the statistics for each entity; kstat instances are numbered
32 starting from zero. Finally, the kstat is given a name unique within
33 its module.
34
35
36 Each kstat may be a special kstat type, an array of name-value pairs,
37 or raw data. In the name-value case, each reported value is given a
38 label, which we refer to as the statistic. Known raw and special kstats
39 are given statistic labels for each of their values by kstat; thus, all
40 published values can be referenced as module:instance:name:statistic.
41
42
43 When invoked without any module operands or options, kstat will match
44 all defined statistics on the system. Example invocations are provided
45 below. All times are displayed as fractional seconds since system boot.
46
48 The tests specified by the following options are logically ANDed, and
49 all matching kstats will be selected. A regular expression containing
50 shell metacharacters must be protected from the shell by enclosing it
51 with the appropriate quotes.
52
53
54 The argument for the -c, -i, -m, -n, and -s options may be specified as
55 a shell glob pattern, or a Perl regular expression enclosed in '/'
56 characters.
57
58 -c class Displays only kstats that match the specified class.
59 class is a kernel-defined string which classifies the
60 "type" of the kstat.
61
62
63 -i instance Displays only kstats that match the specified instance.
64
65
66 -l Lists matching kstat names without displaying values.
67
68
69 -m module Displays only kstats that match the specified module.
70
71
72 -n name Displays only kstats that match the specified name.
73
74
75 -p Displays output in parseable format. All example output
76 in this document is given in this format. If this
77 option is not specified, kstat produces output in a
78 human-readable, table format.
79
80
81 -q Displays no output, but return appropriate exit status
82 for matches against given criteria.
83
84
85 -s statistic Displays only kstats that match the specified statis‐
86 tic.
87
88
89 -T d | u Displays a time stamp before each statistics block,
90 either in date(1) format (d) or as an alphanumeric rep‐
91 resentation of the value returned by time(2) (u).
92
93
95 The following operands are supported:
96
97 module:instance:name:statistic
98
99 Alternate method of specifying module, instance, name, and statis‐
100 tic as described above. Each of the module, instance, name, or
101 statistic specifiers may be a shell glob pattern or a Perl regular
102 expression enclosed by '/' characters. It is possible to use both
103 specifier types within a single operand. Leaving a specifier empty
104 is equivalent to using the '*' glob pattern for that specifier.
105
106
107 interval
108
109 The number of seconds between reports.
110
111
112 count
113
114 The number of reports to be printed.
115
116
118 In the following examples, all the command lines in a block produce the
119 same output, as shown immediately below. The exact statistics and val‐
120 ues will of course vary from machine to machine.
121
122 Example 1 Using the kstat Command
123
124 example$ kstat -p -m unix -i 0 -n system_misc -s 'avenrun*'
125 example$ kstat -p -s 'avenrun*'
126 example$ kstat -p 'unix:0:system_misc:avenrun*'
127 example$ kstat -p ':::avenrun*'
128 example$ kstat -p ':::/^avenrun_\d+min$/'
129
130 unix:0:system_misc:avenrun_15min 3
131 unix:0:system_misc:avenrun_1min 4
132 unix:0:system_misc:avenrun_5min 2
133
134
135
136 Example 2 Using the kstat Command
137
138 example$ kstat -p -m cpu_stat -s 'intr*'
139 example$ kstat -p cpu_stat:::/^intr/
140
141 cpu_stat:0:cpu_stat0:intr 29682330
142 cpu_stat:0:cpu_stat0:intrblk 87
143 cpu_stat:0:cpu_stat0:intrthread 15054222
144 cpu_stat:1:cpu_stat1:intr 426073
145 cpu_stat:1:cpu_stat1:intrblk 51
146 cpu_stat:1:cpu_stat1:intrthread 289668
147 cpu_stat:2:cpu_stat2:intr 134160
148 cpu_stat:2:cpu_stat2:intrblk 0
149 cpu_stat:2:cpu_stat2:intrthread 131
150 cpu_stat:3:cpu_stat3:intr 196566
151 cpu_stat:3:cpu_stat3:intrblk 30
152 cpu_stat:3:cpu_stat3:intrthread 59626
153
154
155
156 Example 3 Using the kstat Command
157
158 example$ kstat -p :::state ':::avenrun*'
159 example$ kstat -p :::state :::/^avenrun/
160
161 cpu_info:0:cpu_info0:state on-line
162 cpu_info:1:cpu_info1:state on-line
163 cpu_info:2:cpu_info2:state on-line
164 cpu_info:3:cpu_info3:state on-line
165 unix:0:system_misc:avenrun_15min 4
166 unix:0:system_misc:avenrun_1min 10
167 unix:0:system_misc:avenrun_5min 3
168
169
170
171 Example 4 Using the kstat Command
172
173 example$ kstat -p 'unix:0:system_misc:avenrun*' 1 3
174 unix:0:system_misc:avenrun_15min 15
175 unix:0:system_misc:avenrun_1min 11
176 unix:0:system_misc:avenrun_5min 21
177
178 unix:0:system_misc:avenrun_15min 15
179 unix:0:system_misc:avenrun_1min 11
180 unix:0:system_misc:avenrun_5min 21
181
182 unix:0:system_misc:avenrun_15min 15
183 unix:0:system_misc:avenrun_1min 11
184 unix:0:system_misc:avenrun_5min 21
185
186
187
188 Example 5 Using the kstat Command
189
190 example$ kstat -p -T d 'unix:0:system_misc:avenrun*' 5 2
191 Thu Jul 22 19:39:50 1999
192 unix:0:system_misc:avenrun_15min 12
193 unix:0:system_misc:avenrun_1min 0
194 unix:0:system_misc:avenrun_5min 11
195
196 Thu Jul 22 19:39:55 1999
197 unix:0:system_misc:avenrun_15min 12
198 unix:0:system_misc:avenrun_1min 0
199 unix:0:system_misc:avenrun_5min 11
200
201
202
203 Example 6 Using the kstat Command
204
205 example$ kstat -p -T u 'unix:0:system_misc:avenrun*'
206 932668656
207 unix:0:system_misc:avenrun_15min 14
208 unix:0:system_misc:avenrun_1min 5
209 unix:0:system_misc:avenrun_5min 18
210
211
212
214 The following exit values are returned:
215
216 0 One or more statistics were matched.
217
218
219 1 No statistics were matched.
220
221
222 2 Invalid command line options were specified.
223
224
225 3 A fatal error occurred.
226
227
229 /dev/kstat kernel statistics driver
230
231
233 See attributes(5) for descriptions of the following attributes:
234
235
236
237
238 ┌─────────────────────────────┬─────────────────────────────┐
239 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
240 ├─────────────────────────────┼─────────────────────────────┤
241 │Availability │SUNWcsu │
242 └─────────────────────────────┴─────────────────────────────┘
243
245 date(1), sh(1), time(2), gmatch(3GEN), kstat(3KSTAT), attributes(5),
246 kstat(7D), sd(7D), kstat(9S)
247
249 If the pattern argument contains glob or Perl RE metacharacters which
250 are also shell metacharacters, it will be necessary to enclose the pat‐
251 tern with appropriate shell quotes.
252
253
254
255SunOS 5.11 23 Mar 2009 kstat(1M)