]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - cmd/dbufstat/dbufstat.in
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / cmd / dbufstat / dbufstat.in
1 #!/usr/bin/env @PYTHON_SHEBANG@
2 #
3 # Print out statistics for all cached dmu buffers.  This information
4 # is available through the dbufs kstat and may be post-processed as
5 # needed by the script.
6 #
7 # CDDL HEADER START
8 #
9 # The contents of this file are subject to the terms of the
10 # Common Development and Distribution License, Version 1.0 only
11 # (the "License").  You may not use this file except in compliance
12 # with the License.
13 #
14 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
15 # or http://www.opensolaris.org/os/licensing.
16 # See the License for the specific language governing permissions
17 # and limitations under the License.
18 #
19 # When distributing Covered Code, include this CDDL HEADER in each
20 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
21 # If applicable, add the following below this CDDL HEADER, with the
22 # fields enclosed by brackets "[]" replaced with your own identifying
23 # information: Portions Copyright [yyyy] [name of copyright owner]
24 #
25 # CDDL HEADER END
26 #
27 # Copyright (C) 2013 Lawrence Livermore National Security, LLC.
28 # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
29 #
30 # This script must remain compatible with Python 2.6+ and Python 3.4+.
31 #
32
33 import sys
34 import getopt
35 import errno
36 import re
37
38 bhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize"]
39 bxhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize",
40          "meta", "state", "dbholds", "dbc", "list", "atype", "flags",
41          "count", "asize", "access", "mru", "gmru", "mfu", "gmfu", "l2",
42          "l2_dattr", "l2_asize", "l2_comp", "aholds", "dtype", "btype",
43          "data_bs", "meta_bs", "bsize", "lvls", "dholds", "blocks", "dsize"]
44 bincompat = ["cached", "direct", "indirect", "bonus", "spill"]
45
46 dhdr = ["pool", "objset", "object", "dtype", "cached"]
47 dxhdr = ["pool", "objset", "object", "dtype", "btype", "data_bs", "meta_bs",
48          "bsize", "lvls", "dholds", "blocks", "dsize", "cached", "direct",
49          "indirect", "bonus", "spill"]
50 dincompat = ["level", "blkid", "offset", "dbsize", "meta", "state", "dbholds",
51              "dbc", "list", "atype", "flags", "count", "asize", "access",
52              "mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr", "l2_asize",
53              "l2_comp", "aholds"]
54
55 thdr = ["pool", "objset", "dtype", "cached"]
56 txhdr = ["pool", "objset", "dtype", "cached", "direct", "indirect",
57          "bonus", "spill"]
58 tincompat = ["object", "level", "blkid", "offset", "dbsize", "meta", "state",
59              "dbc", "dbholds", "list", "atype", "flags", "count", "asize",
60              "access", "mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr",
61              "l2_asize", "l2_comp", "aholds", "btype", "data_bs", "meta_bs",
62              "bsize", "lvls", "dholds", "blocks", "dsize"]
63
64 cols = {
65     # hdr:        [size, scale, description]
66     "pool":       [15,   -1, "pool name"],
67     "objset":     [6,    -1, "dataset identification number"],
68     "object":     [10,   -1, "object number"],
69     "level":      [5,    -1, "indirection level of buffer"],
70     "blkid":      [8,    -1, "block number of buffer"],
71     "offset":     [12, 1024, "offset in object of buffer"],
72     "dbsize":     [7,  1024, "size of buffer"],
73     "meta":       [4,    -1, "is this buffer metadata?"],
74     "state":      [5,    -1, "state of buffer (read, cached, etc)"],
75     "dbholds":    [7,  1000, "number of holds on buffer"],
76     "dbc":        [3,    -1, "in dbuf cache"],
77     "list":       [4,    -1, "which ARC list contains this buffer"],
78     "atype":      [7,    -1, "ARC header type (data or metadata)"],
79     "flags":      [9,    -1, "ARC read flags"],
80     "count":      [5,    -1, "ARC data count"],
81     "asize":      [7,  1024, "size of this ARC buffer"],
82     "access":     [10,   -1, "time this ARC buffer was last accessed"],
83     "mru":        [5,  1000, "hits while on the ARC's MRU list"],
84     "gmru":       [5,  1000, "hits while on the ARC's MRU ghost list"],
85     "mfu":        [5,  1000, "hits while on the ARC's MFU list"],
86     "gmfu":       [5,  1000, "hits while on the ARC's MFU ghost list"],
87     "l2":         [5,  1000, "hits while on the L2ARC"],
88     "l2_dattr":   [8,    -1, "L2ARC disk address/offset"],
89     "l2_asize":   [8,  1024, "L2ARC alloc'd size (depending on compression)"],
90     "l2_comp":    [21,   -1, "L2ARC compression algorithm for buffer"],
91     "aholds":     [6,  1000, "number of holds on this ARC buffer"],
92     "dtype":      [27,   -1, "dnode type"],
93     "btype":      [27,   -1, "bonus buffer type"],
94     "data_bs":    [7,  1024, "data block size"],
95     "meta_bs":    [7,  1024, "metadata block size"],
96     "bsize":      [6,  1024, "bonus buffer size"],
97     "lvls":       [6,    -1, "number of indirection levels"],
98     "dholds":     [6,  1000, "number of holds on dnode"],
99     "blocks":     [8,  1000, "number of allocated blocks"],
100     "dsize":      [12, 1024, "size of dnode"],
101     "cached":     [6,  1024, "bytes cached for all blocks"],
102     "direct":     [6,  1024, "bytes cached for direct blocks"],
103     "indirect":   [8,  1024, "bytes cached for indirect blocks"],
104     "bonus":      [5,  1024, "bytes cached for bonus buffer"],
105     "spill":      [5,  1024, "bytes cached for spill block"],
106 }
107
108 hdr = None
109 xhdr = None
110 sep = "  "  # Default separator is 2 spaces
111 cmd = ("Usage: dbufstat [-bdhnrtvx] [-i file] [-f fields] [-o file] "
112        "[-s string] [-F filter]\n")
113 raw = 0
114
115
116 def print_incompat_helper(incompat):
117     cnt = 0
118     for key in sorted(incompat):
119         if cnt is 0:
120             sys.stderr.write("\t")
121         elif cnt > 8:
122             sys.stderr.write(",\n\t")
123             cnt = 0
124         else:
125             sys.stderr.write(", ")
126
127         sys.stderr.write("%s" % key)
128         cnt += 1
129
130     sys.stderr.write("\n\n")
131
132
133 def detailed_usage():
134     sys.stderr.write("%s\n" % cmd)
135
136     sys.stderr.write("Field definitions incompatible with '-b' option:\n")
137     print_incompat_helper(bincompat)
138
139     sys.stderr.write("Field definitions incompatible with '-d' option:\n")
140     print_incompat_helper(dincompat)
141
142     sys.stderr.write("Field definitions incompatible with '-t' option:\n")
143     print_incompat_helper(tincompat)
144
145     sys.stderr.write("Field definitions are as follows:\n")
146     for key in sorted(cols.keys()):
147         sys.stderr.write("%11s : %s\n" % (key, cols[key][2]))
148     sys.stderr.write("\n")
149
150     sys.exit(0)
151
152
153 def usage():
154     sys.stderr.write("%s\n" % cmd)
155     sys.stderr.write("\t -b : Print table of information for each dbuf\n")
156     sys.stderr.write("\t -d : Print table of information for each dnode\n")
157     sys.stderr.write("\t -h : Print this help message\n")
158     sys.stderr.write("\t -n : Exclude header from output\n")
159     sys.stderr.write("\t -r : Print raw values\n")
160     sys.stderr.write("\t -t : Print table of information for each dnode type"
161                      "\n")
162     sys.stderr.write("\t -v : List all possible field headers and definitions"
163                      "\n")
164     sys.stderr.write("\t -x : Print extended stats\n")
165     sys.stderr.write("\t -i : Redirect input from the specified file\n")
166     sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
167     sys.stderr.write("\t -o : Redirect output to the specified file\n")
168     sys.stderr.write("\t -s : Override default field separator with custom "
169                      "character or string\n")
170     sys.stderr.write("\t -F : Filter output by value or regex\n")
171     sys.stderr.write("\nExamples:\n")
172     sys.stderr.write("\tdbufstat -d -o /tmp/d.log\n")
173     sys.stderr.write("\tdbufstat -t -s \",\" -o /tmp/t.log\n")
174     sys.stderr.write("\tdbufstat -v\n")
175     sys.stderr.write("\tdbufstat -d -f pool,object,objset,dsize,cached\n")
176     sys.stderr.write("\tdbufstat -bx -F dbc=1,objset=54,pool=testpool\n")
177     sys.stderr.write("\n")
178
179     sys.exit(1)
180
181
182 def prettynum(sz, scale, num=0):
183     global raw
184
185     suffix = [' ', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']
186     index = 0
187     save = 0
188
189     if raw or scale == -1:
190         return "%*s" % (sz, num)
191
192     # Rounding error, return 0
193     elif 0 < num < 1:
194         num = 0
195
196     while num > scale and index < 5:
197         save = num
198         num = num / scale
199         index += 1
200
201     if index == 0:
202         return "%*d" % (sz, num)
203
204     if (save / scale) < 10:
205         return "%*.1f%s" % (sz - 1, num, suffix[index])
206     else:
207         return "%*d%s" % (sz - 1, num, suffix[index])
208
209
210 def print_values(v):
211     global hdr
212     global sep
213
214     try:
215         for col in hdr:
216             sys.stdout.write("%s%s" % (
217                 prettynum(cols[col][0], cols[col][1], v[col]), sep))
218         sys.stdout.write("\n")
219     except IOError as e:
220         if e.errno == errno.EPIPE:
221             sys.exit(1)
222
223
224 def print_header():
225     global hdr
226     global sep
227
228     try:
229         for col in hdr:
230             sys.stdout.write("%*s%s" % (cols[col][0], col, sep))
231         sys.stdout.write("\n")
232     except IOError as e:
233         if e.errno == errno.EPIPE:
234             sys.exit(1)
235
236
237 def get_typestring(t):
238     ot_strings = [
239                     "DMU_OT_NONE",
240                     # general:
241                     "DMU_OT_OBJECT_DIRECTORY",
242                     "DMU_OT_OBJECT_ARRAY",
243                     "DMU_OT_PACKED_NVLIST",
244                     "DMU_OT_PACKED_NVLIST_SIZE",
245                     "DMU_OT_BPOBJ",
246                     "DMU_OT_BPOBJ_HDR",
247                     # spa:
248                     "DMU_OT_SPACE_MAP_HEADER",
249                     "DMU_OT_SPACE_MAP",
250                     # zil:
251                     "DMU_OT_INTENT_LOG",
252                     # dmu:
253                     "DMU_OT_DNODE",
254                     "DMU_OT_OBJSET",
255                     # dsl:
256                     "DMU_OT_DSL_DIR",
257                     "DMU_OT_DSL_DIR_CHILD_MAP",
258                     "DMU_OT_DSL_DS_SNAP_MAP",
259                     "DMU_OT_DSL_PROPS",
260                     "DMU_OT_DSL_DATASET",
261                     # zpl:
262                     "DMU_OT_ZNODE",
263                     "DMU_OT_OLDACL",
264                     "DMU_OT_PLAIN_FILE_CONTENTS",
265                     "DMU_OT_DIRECTORY_CONTENTS",
266                     "DMU_OT_MASTER_NODE",
267                     "DMU_OT_UNLINKED_SET",
268                     # zvol:
269                     "DMU_OT_ZVOL",
270                     "DMU_OT_ZVOL_PROP",
271                     # other; for testing only!
272                     "DMU_OT_PLAIN_OTHER",
273                     "DMU_OT_UINT64_OTHER",
274                     "DMU_OT_ZAP_OTHER",
275                     # new object types:
276                     "DMU_OT_ERROR_LOG",
277                     "DMU_OT_SPA_HISTORY",
278                     "DMU_OT_SPA_HISTORY_OFFSETS",
279                     "DMU_OT_POOL_PROPS",
280                     "DMU_OT_DSL_PERMS",
281                     "DMU_OT_ACL",
282                     "DMU_OT_SYSACL",
283                     "DMU_OT_FUID",
284                     "DMU_OT_FUID_SIZE",
285                     "DMU_OT_NEXT_CLONES",
286                     "DMU_OT_SCAN_QUEUE",
287                     "DMU_OT_USERGROUP_USED",
288                     "DMU_OT_USERGROUP_QUOTA",
289                     "DMU_OT_USERREFS",
290                     "DMU_OT_DDT_ZAP",
291                     "DMU_OT_DDT_STATS",
292                     "DMU_OT_SA",
293                     "DMU_OT_SA_MASTER_NODE",
294                     "DMU_OT_SA_ATTR_REGISTRATION",
295                     "DMU_OT_SA_ATTR_LAYOUTS",
296                     "DMU_OT_SCAN_XLATE",
297                     "DMU_OT_DEDUP",
298                     "DMU_OT_DEADLIST",
299                     "DMU_OT_DEADLIST_HDR",
300                     "DMU_OT_DSL_CLONES",
301                     "DMU_OT_BPOBJ_SUBOBJ"]
302     otn_strings = {
303                     0x80: "DMU_OTN_UINT8_DATA",
304                     0xc0: "DMU_OTN_UINT8_METADATA",
305                     0x81: "DMU_OTN_UINT16_DATA",
306                     0xc1: "DMU_OTN_UINT16_METADATA",
307                     0x82: "DMU_OTN_UINT32_DATA",
308                     0xc2: "DMU_OTN_UINT32_METADATA",
309                     0x83: "DMU_OTN_UINT64_DATA",
310                     0xc3: "DMU_OTN_UINT64_METADATA",
311                     0x84: "DMU_OTN_ZAP_DATA",
312                     0xc4: "DMU_OTN_ZAP_METADATA",
313                     0xa0: "DMU_OTN_UINT8_ENC_DATA",
314                     0xe0: "DMU_OTN_UINT8_ENC_METADATA",
315                     0xa1: "DMU_OTN_UINT16_ENC_DATA",
316                     0xe1: "DMU_OTN_UINT16_ENC_METADATA",
317                     0xa2: "DMU_OTN_UINT32_ENC_DATA",
318                     0xe2: "DMU_OTN_UINT32_ENC_METADATA",
319                     0xa3: "DMU_OTN_UINT64_ENC_DATA",
320                     0xe3: "DMU_OTN_UINT64_ENC_METADATA",
321                     0xa4: "DMU_OTN_ZAP_ENC_DATA",
322                     0xe4: "DMU_OTN_ZAP_ENC_METADATA"}
323
324     # If "-rr" option is used, don't convert to string representation
325     if raw > 1:
326         return "%i" % t
327
328     try:
329         if t < len(ot_strings):
330             return ot_strings[t]
331         else:
332             return otn_strings[t]
333     except (IndexError, KeyError):
334         return "(UNKNOWN)"
335
336
337 def get_compstring(c):
338     comp_strings = ["ZIO_COMPRESS_INHERIT", "ZIO_COMPRESS_ON",
339                     "ZIO_COMPRESS_OFF",     "ZIO_COMPRESS_LZJB",
340                     "ZIO_COMPRESS_EMPTY",   "ZIO_COMPRESS_GZIP_1",
341                     "ZIO_COMPRESS_GZIP_2",  "ZIO_COMPRESS_GZIP_3",
342                     "ZIO_COMPRESS_GZIP_4",  "ZIO_COMPRESS_GZIP_5",
343                     "ZIO_COMPRESS_GZIP_6",  "ZIO_COMPRESS_GZIP_7",
344                     "ZIO_COMPRESS_GZIP_8",  "ZIO_COMPRESS_GZIP_9",
345                     "ZIO_COMPRESS_ZLE",     "ZIO_COMPRESS_LZ4",
346                     "ZIO_COMPRESS_ZSTD",    "ZIO_COMPRESS_FUNCTION"]
347
348     # If "-rr" option is used, don't convert to string representation
349     if raw > 1:
350         return "%i" % c
351
352     try:
353         return comp_strings[c]
354     except IndexError:
355         return "%i" % c
356
357
358 def parse_line(line, labels):
359     global hdr
360
361     new = dict()
362     val = None
363     for col in hdr:
364         # These are "special" fields computed in the update_dict
365         # function, prevent KeyError exception on labels[col] for these.
366         if col not in ['bonus', 'cached', 'direct', 'indirect', 'spill']:
367             val = line[labels[col]]
368
369         if col in ['pool', 'flags']:
370             new[col] = str(val)
371         elif col in ['dtype', 'btype']:
372             new[col] = get_typestring(int(val))
373         elif col in ['l2_comp']:
374             new[col] = get_compstring(int(val))
375         else:
376             new[col] = int(val)
377
378     return new
379
380
381 def update_dict(d, k, line, labels):
382     pool = line[labels['pool']]
383     objset = line[labels['objset']]
384     key = line[labels[k]]
385
386     dbsize = int(line[labels['dbsize']])
387     blkid = int(line[labels['blkid']])
388     level = int(line[labels['level']])
389
390     if pool not in d:
391         d[pool] = dict()
392
393     if objset not in d[pool]:
394         d[pool][objset] = dict()
395
396     if key not in d[pool][objset]:
397         d[pool][objset][key] = parse_line(line, labels)
398         d[pool][objset][key]['bonus'] = 0
399         d[pool][objset][key]['cached'] = 0
400         d[pool][objset][key]['direct'] = 0
401         d[pool][objset][key]['indirect'] = 0
402         d[pool][objset][key]['spill'] = 0
403
404     d[pool][objset][key]['cached'] += dbsize
405
406     if blkid == -1:
407         d[pool][objset][key]['bonus'] += dbsize
408     elif blkid == -2:
409         d[pool][objset][key]['spill'] += dbsize
410     else:
411         if level == 0:
412             d[pool][objset][key]['direct'] += dbsize
413         else:
414             d[pool][objset][key]['indirect'] += dbsize
415
416     return d
417
418
419 def skip_line(vals, filters):
420     '''
421     Determines if a line should be skipped during printing
422     based on a set of filters
423     '''
424     if len(filters) == 0:
425         return False
426
427     for key in vals:
428         if key in filters:
429             val = prettynum(cols[key][0], cols[key][1], vals[key]).strip()
430             # we want a full match here
431             if re.match("(?:" + filters[key] + r")\Z", val) is None:
432                 return True
433
434     return False
435
436
437 def print_dict(d, filters, noheader):
438     if not noheader:
439         print_header()
440     for pool in list(d.keys()):
441         for objset in list(d[pool].keys()):
442             for v in list(d[pool][objset].values()):
443                 if not skip_line(v, filters):
444                     print_values(v)
445
446
447 def dnodes_build_dict(filehandle):
448     labels = dict()
449     dnodes = dict()
450
451     # First 3 lines are header information, skip the first two
452     for i in range(2):
453         next(filehandle)
454
455     # The third line contains the labels and index locations
456     for i, v in enumerate(next(filehandle).split()):
457         labels[v] = i
458
459     # The rest of the file is buffer information
460     for line in filehandle:
461         update_dict(dnodes, 'object', line.split(), labels)
462
463     return dnodes
464
465
466 def types_build_dict(filehandle):
467     labels = dict()
468     types = dict()
469
470     # First 3 lines are header information, skip the first two
471     for i in range(2):
472         next(filehandle)
473
474     # The third line contains the labels and index locations
475     for i, v in enumerate(next(filehandle).split()):
476         labels[v] = i
477
478     # The rest of the file is buffer information
479     for line in filehandle:
480         update_dict(types, 'dtype', line.split(), labels)
481
482     return types
483
484
485 def buffers_print_all(filehandle, filters, noheader):
486     labels = dict()
487
488     # First 3 lines are header information, skip the first two
489     for i in range(2):
490         next(filehandle)
491
492     # The third line contains the labels and index locations
493     for i, v in enumerate(next(filehandle).split()):
494         labels[v] = i
495
496     if not noheader:
497         print_header()
498
499     # The rest of the file is buffer information
500     for line in filehandle:
501         vals = parse_line(line.split(), labels)
502         if not skip_line(vals, filters):
503             print_values(vals)
504
505
506 def main():
507     global hdr
508     global sep
509     global raw
510
511     desired_cols = None
512     bflag = False
513     dflag = False
514     hflag = False
515     ifile = None
516     ofile = None
517     tflag = False
518     vflag = False
519     xflag = False
520     nflag = False
521     filters = dict()
522
523     try:
524         opts, args = getopt.getopt(
525             sys.argv[1:],
526             "bdf:hi:o:rs:tvxF:n",
527             [
528                 "buffers",
529                 "dnodes",
530                 "columns",
531                 "help",
532                 "infile",
533                 "outfile",
534                 "separator",
535                 "types",
536                 "verbose",
537                 "extended",
538                 "filter"
539             ]
540         )
541     except getopt.error:
542         usage()
543         opts = None
544
545     for opt, arg in opts:
546         if opt in ('-b', '--buffers'):
547             bflag = True
548         if opt in ('-d', '--dnodes'):
549             dflag = True
550         if opt in ('-f', '--columns'):
551             desired_cols = arg
552         if opt in ('-h', '--help'):
553             hflag = True
554         if opt in ('-i', '--infile'):
555             ifile = arg
556         if opt in ('-o', '--outfile'):
557             ofile = arg
558         if opt in ('-r', '--raw'):
559             raw += 1
560         if opt in ('-s', '--separator'):
561             sep = arg
562         if opt in ('-t', '--types'):
563             tflag = True
564         if opt in ('-v', '--verbose'):
565             vflag = True
566         if opt in ('-x', '--extended'):
567             xflag = True
568         if opt in ('-n', '--noheader'):
569             nflag = True
570         if opt in ('-F', '--filter'):
571             fils = [x.strip() for x in arg.split(",")]
572
573             for fil in fils:
574                 f = [x.strip() for x in fil.split("=")]
575
576                 if len(f) != 2:
577                     sys.stderr.write("Invalid filter '%s'.\n" % fil)
578                     sys.exit(1)
579
580                 if f[0] not in cols:
581                     sys.stderr.write("Invalid field '%s' in filter.\n" % f[0])
582                     sys.exit(1)
583
584                 if f[0] in filters:
585                     sys.stderr.write("Field '%s' specified multiple times in "
586                                      "filter.\n" % f[0])
587                     sys.exit(1)
588
589                 try:
590                     re.compile("(?:" + f[1] + r")\Z")
591                 except re.error:
592                     sys.stderr.write("Invalid regex for field '%s' in "
593                                      "filter.\n" % f[0])
594                     sys.exit(1)
595
596                 filters[f[0]] = f[1]
597
598     if hflag or (xflag and desired_cols):
599         usage()
600
601     if vflag:
602         detailed_usage()
603
604     # Ensure at most only one of b, d, or t flags are set
605     if (bflag and dflag) or (bflag and tflag) or (dflag and tflag):
606         usage()
607
608     if bflag:
609         hdr = bxhdr if xflag else bhdr
610     elif tflag:
611         hdr = txhdr if xflag else thdr
612     else:  # Even if dflag is False, it's the default if none set
613         dflag = True
614         hdr = dxhdr if xflag else dhdr
615
616     if desired_cols:
617         hdr = desired_cols.split(",")
618
619         invalid = []
620         incompat = []
621         for ele in hdr:
622             if ele not in cols:
623                 invalid.append(ele)
624             elif ((bflag and bincompat and ele in bincompat) or
625                   (dflag and dincompat and ele in dincompat) or
626                   (tflag and tincompat and ele in tincompat)):
627                     incompat.append(ele)
628
629         if len(invalid) > 0:
630             sys.stderr.write("Invalid column definition! -- %s\n" % invalid)
631             usage()
632
633         if len(incompat) > 0:
634             sys.stderr.write("Incompatible field specified! -- %s\n" %
635                              incompat)
636             usage()
637
638     if ofile:
639         try:
640             tmp = open(ofile, "w")
641             sys.stdout = tmp
642
643         except IOError:
644             sys.stderr.write("Cannot open %s for writing\n" % ofile)
645             sys.exit(1)
646
647     if not ifile:
648         ifile = '/proc/spl/kstat/zfs/dbufs'
649
650     if ifile is not "-":
651         try:
652             tmp = open(ifile, "r")
653             sys.stdin = tmp
654         except IOError:
655             sys.stderr.write("Cannot open %s for reading\n" % ifile)
656             sys.exit(1)
657
658     if bflag:
659         buffers_print_all(sys.stdin, filters, nflag)
660
661     if dflag:
662         print_dict(dnodes_build_dict(sys.stdin), filters, nflag)
663
664     if tflag:
665         print_dict(types_build_dict(sys.stdin), filters, nflag)
666
667
668 if __name__ == '__main__':
669     main()