pep8 code readability changes
Update the code to follow the pep8 style guide. References: http://www.python.org/dev/peps/pep-0008/ Signed-off-by: Matthew Thode <prometheanfire@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #1838
This commit is contained in:
parent
7a4f54688e
commit
23bc1f91fc
|
@ -96,9 +96,9 @@ cols = {
|
||||||
|
|
||||||
v = {}
|
v = {}
|
||||||
hdr = ["time", "read", "miss", "miss%", "dmis", "dm%", "pmis", "pm%", "mmis",
|
hdr = ["time", "read", "miss", "miss%", "dmis", "dm%", "pmis", "pm%", "mmis",
|
||||||
"mm%", "arcsz", "c"]
|
"mm%", "arcsz", "c"]
|
||||||
xhdr = ["time", "mfu", "mru", "mfug", "mrug", "eskip", "mtxmis", "rmis",
|
xhdr = ["time", "mfu", "mru", "mfug", "mrug", "eskip", "mtxmis", "rmis",
|
||||||
"dread", "pread", "read"]
|
"dread", "pread", "read"]
|
||||||
sint = 1 # Default interval is 1 second
|
sint = 1 # Default interval is 1 second
|
||||||
count = 1 # Default count is 1
|
count = 1 # Default count is 1
|
||||||
hdr_intr = 20 # Print header every 20 lines of output
|
hdr_intr = 20 # Print header every 20 lines of output
|
||||||
|
@ -107,7 +107,7 @@ sep = " " # Default separator is 2 spaces
|
||||||
version = "0.4"
|
version = "0.4"
|
||||||
l2exist = False
|
l2exist = False
|
||||||
cmd = ("Usage: arcstat.py [-hvx] [-f fields] [-o file] [-s string] [interval "
|
cmd = ("Usage: arcstat.py [-hvx] [-f fields] [-o file] [-s string] [interval "
|
||||||
"[count]]\n")
|
"[count]]\n")
|
||||||
cur = {}
|
cur = {}
|
||||||
d = {}
|
d = {}
|
||||||
out = None
|
out = None
|
||||||
|
@ -129,12 +129,12 @@ def usage():
|
||||||
sys.stderr.write("%s\n" % cmd)
|
sys.stderr.write("%s\n" % cmd)
|
||||||
sys.stderr.write("\t -h : Print this help message\n")
|
sys.stderr.write("\t -h : Print this help message\n")
|
||||||
sys.stderr.write("\t -v : List all possible field headers and definitions"
|
sys.stderr.write("\t -v : List all possible field headers and definitions"
|
||||||
"\n")
|
"\n")
|
||||||
sys.stderr.write("\t -x : Print extended stats\n")
|
sys.stderr.write("\t -x : Print extended stats\n")
|
||||||
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
|
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
|
||||||
sys.stderr.write("\t -o : Redirect output to the specified file\n")
|
sys.stderr.write("\t -o : Redirect output to the specified file\n")
|
||||||
sys.stderr.write("\t -s : Override default field separator with custom "
|
sys.stderr.write("\t -s : Override default field separator with custom "
|
||||||
"character or string\n")
|
"character or string\n")
|
||||||
sys.stderr.write("\nExamples:\n")
|
sys.stderr.write("\nExamples:\n")
|
||||||
sys.stderr.write("\tarcstat.py -o /tmp/a.log 2 10\n")
|
sys.stderr.write("\tarcstat.py -o /tmp/a.log 2 10\n")
|
||||||
sys.stderr.write("\tarcstat.py -s \",\" -o /tmp/a.log 2 10\n")
|
sys.stderr.write("\tarcstat.py -s \",\" -o /tmp/a.log 2 10\n")
|
||||||
|
@ -217,7 +217,7 @@ def print_values():
|
||||||
sys.stdout.write("%s%s" % (
|
sys.stdout.write("%s%s" % (
|
||||||
prettynum(cols[col][0], cols[col][1], v[col]),
|
prettynum(cols[col][0], cols[col][1], v[col]),
|
||||||
sep
|
sep
|
||||||
))
|
))
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n")
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,9 +326,8 @@ def init():
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if len(incompat) > 0:
|
if len(incompat) > 0:
|
||||||
sys.stderr.write("Incompatible field specified! -- %s\n" % (
|
sys.stderr.write("Incompatible field specified! -- %s\n" %
|
||||||
incompat,
|
incompat)
|
||||||
))
|
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if opfile:
|
if opfile:
|
||||||
|
@ -363,16 +362,16 @@ def calculate():
|
||||||
|
|
||||||
v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) / sint
|
v["phit"] = (d["prefetch_data_hits"] + d["prefetch_metadata_hits"]) / sint
|
||||||
v["pmis"] = (d["prefetch_data_misses"] +
|
v["pmis"] = (d["prefetch_data_misses"] +
|
||||||
d["prefetch_metadata_misses"]) / sint
|
d["prefetch_metadata_misses"]) / sint
|
||||||
|
|
||||||
v["pread"] = v["phit"] + v["pmis"]
|
v["pread"] = v["phit"] + v["pmis"]
|
||||||
v["ph%"] = 100 * v["phit"] / v["pread"] if v["pread"] > 0 else 0
|
v["ph%"] = 100 * v["phit"] / v["pread"] if v["pread"] > 0 else 0
|
||||||
v["pm%"] = 100 - v["ph%"] if v["pread"] > 0 else 0
|
v["pm%"] = 100 - v["ph%"] if v["pread"] > 0 else 0
|
||||||
|
|
||||||
v["mhit"] = (d["prefetch_metadata_hits"] +
|
v["mhit"] = (d["prefetch_metadata_hits"] +
|
||||||
d["demand_metadata_hits"]) / sint
|
d["demand_metadata_hits"]) / sint
|
||||||
v["mmis"] = (d["prefetch_metadata_misses"] +
|
v["mmis"] = (d["prefetch_metadata_misses"] +
|
||||||
d["demand_metadata_misses"]) / sint
|
d["demand_metadata_misses"]) / sint
|
||||||
|
|
||||||
v["mread"] = v["mhit"] + v["mmis"]
|
v["mread"] = v["mhit"] + v["mmis"]
|
||||||
v["mh%"] = 100 * v["mhit"] / v["mread"] if v["mread"] > 0 else 0
|
v["mh%"] = 100 * v["mhit"] / v["mread"] if v["mread"] > 0 else 0
|
||||||
|
|
|
@ -32,30 +32,31 @@ import sys
|
||||||
import getopt
|
import getopt
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
bhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize"]
|
bhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize"]
|
||||||
bxhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize",
|
bxhdr = ["pool", "objset", "object", "level", "blkid", "offset", "dbsize",
|
||||||
"meta", "state", "dbholds", "list", "atype", "index", "flags", "count",
|
"meta", "state", "dbholds", "list", "atype", "index", "flags",
|
||||||
"asize", "access", "mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr",
|
"count", "asize", "access", "mru", "gmru", "mfu", "gmfu", "l2",
|
||||||
"l2_asize", "l2_comp", "aholds", "dtype", "btype", "data_bs", "meta_bs",
|
"l2_dattr", "l2_asize", "l2_comp", "aholds", "dtype", "btype",
|
||||||
"bsize", "lvls", "dholds", "blocks", "dsize"]
|
"data_bs", "meta_bs", "bsize", "lvls", "dholds", "blocks", "dsize"]
|
||||||
bincompat = ["cached", "direct", "indirect", "bonus", "spill"]
|
bincompat = ["cached", "direct", "indirect", "bonus", "spill"]
|
||||||
|
|
||||||
dhdr = ["pool", "objset", "object", "dtype", "cached"]
|
dhdr = ["pool", "objset", "object", "dtype", "cached"]
|
||||||
dxhdr = ["pool", "objset", "object", "dtype", "btype", "data_bs", "meta_bs",
|
dxhdr = ["pool", "objset", "object", "dtype", "btype", "data_bs", "meta_bs",
|
||||||
"bsize", "lvls", "dholds", "blocks", "dsize", "cached", "direct",
|
"bsize", "lvls", "dholds", "blocks", "dsize", "cached", "direct",
|
||||||
"indirect", "bonus", "spill"]
|
"indirect", "bonus", "spill"]
|
||||||
dincompat = ["level", "blkid", "offset", "dbsize", "meta", "state", "dbholds",
|
dincompat = ["level", "blkid", "offset", "dbsize", "meta", "state", "dbholds",
|
||||||
"list", "atype", "index", "flags", "count", "asize", "access", "mru",
|
"list", "atype", "index", "flags", "count", "asize", "access",
|
||||||
"gmru", "mfu", "gmfu", "l2", "l2_dattr", "l2_asize", "l2_comp", "aholds"]
|
"mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr", "l2_asize",
|
||||||
|
"l2_comp", "aholds"]
|
||||||
|
|
||||||
thdr = ["pool", "objset", "dtype", "cached"]
|
thdr = ["pool", "objset", "dtype", "cached"]
|
||||||
txhdr = ["pool", "objset", "dtype", "cached", "direct", "indirect",
|
txhdr = ["pool", "objset", "dtype", "cached", "direct", "indirect",
|
||||||
"bonus", "spill"]
|
"bonus", "spill"]
|
||||||
tincompat = ["object", "level", "blkid", "offset", "dbsize", "meta", "state",
|
tincompat = ["object", "level", "blkid", "offset", "dbsize", "meta", "state",
|
||||||
"dbholds", "list", "atype", "index", "flags", "count", "asize", "access",
|
"dbholds", "list", "atype", "index", "flags", "count", "asize",
|
||||||
"mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr", "l2_asize", "l2_comp",
|
"access", "mru", "gmru", "mfu", "gmfu", "l2", "l2_dattr",
|
||||||
"aholds", "btype", "data_bs", "meta_bs", "bsize", "lvls", "dholds",
|
"l2_asize", "l2_comp", "aholds", "btype", "data_bs", "meta_bs",
|
||||||
"blocks", "dsize"]
|
"bsize", "lvls", "dholds", "blocks", "dsize"]
|
||||||
|
|
||||||
cols = {
|
cols = {
|
||||||
# hdr: [size, scale, description]
|
# hdr: [size, scale, description]
|
||||||
|
@ -101,13 +102,14 @@ cols = {
|
||||||
"spill": [5, 1024, "bytes cached for spill block"],
|
"spill": [5, 1024, "bytes cached for spill block"],
|
||||||
}
|
}
|
||||||
|
|
||||||
hdr = None
|
hdr = None
|
||||||
xhdr = None
|
xhdr = None
|
||||||
sep = " " # Default separator is 2 spaces
|
sep = " " # Default separator is 2 spaces
|
||||||
cmd = ("Usage: dbufstat.py [-bdhrtvx] [-i file] [-f fields] [-o file] "
|
cmd = ("Usage: dbufstat.py [-bdhrtvx] [-i file] [-f fields] [-o file] "
|
||||||
"[-s string]\n")
|
"[-s string]\n")
|
||||||
raw = 0
|
raw = 0
|
||||||
|
|
||||||
|
|
||||||
def print_incompat_helper(incompat):
|
def print_incompat_helper(incompat):
|
||||||
cnt = 0
|
cnt = 0
|
||||||
for key in sorted(incompat):
|
for key in sorted(incompat):
|
||||||
|
@ -124,6 +126,7 @@ def print_incompat_helper(incompat):
|
||||||
|
|
||||||
sys.stderr.write("\n\n")
|
sys.stderr.write("\n\n")
|
||||||
|
|
||||||
|
|
||||||
def detailed_usage():
|
def detailed_usage():
|
||||||
sys.stderr.write("%s\n" % cmd)
|
sys.stderr.write("%s\n" % cmd)
|
||||||
|
|
||||||
|
@ -143,21 +146,23 @@ def detailed_usage():
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
sys.stderr.write("%s\n" % cmd)
|
sys.stderr.write("%s\n" % cmd)
|
||||||
sys.stderr.write("\t -b : Print table of information for each dbuf\n")
|
sys.stderr.write("\t -b : Print table of information for each dbuf\n")
|
||||||
sys.stderr.write("\t -d : Print table of information for each dnode\n")
|
sys.stderr.write("\t -d : Print table of information for each dnode\n")
|
||||||
sys.stderr.write("\t -h : Print this help message\n")
|
sys.stderr.write("\t -h : Print this help message\n")
|
||||||
sys.stderr.write("\t -r : Print raw values\n")
|
sys.stderr.write("\t -r : Print raw values\n")
|
||||||
sys.stderr.write("\t -t : Print table of information for each dnode type\n")
|
sys.stderr.write("\t -t : Print table of information for each dnode type"
|
||||||
|
"\n")
|
||||||
sys.stderr.write("\t -v : List all possible field headers and definitions"
|
sys.stderr.write("\t -v : List all possible field headers and definitions"
|
||||||
"\n")
|
"\n")
|
||||||
sys.stderr.write("\t -x : Print extended stats\n")
|
sys.stderr.write("\t -x : Print extended stats\n")
|
||||||
sys.stderr.write("\t -i : Redirect input from the specified file\n")
|
sys.stderr.write("\t -i : Redirect input from the specified file\n")
|
||||||
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
|
sys.stderr.write("\t -f : Specify specific fields to print (see -v)\n")
|
||||||
sys.stderr.write("\t -o : Redirect output to the specified file\n")
|
sys.stderr.write("\t -o : Redirect output to the specified file\n")
|
||||||
sys.stderr.write("\t -s : Override default field separator with custom "
|
sys.stderr.write("\t -s : Override default field separator with custom "
|
||||||
"character or string\n")
|
"character or string\n")
|
||||||
sys.stderr.write("\nExamples:\n")
|
sys.stderr.write("\nExamples:\n")
|
||||||
sys.stderr.write("\tdbufstat.py -d -o /tmp/d.log\n")
|
sys.stderr.write("\tdbufstat.py -d -o /tmp/d.log\n")
|
||||||
sys.stderr.write("\tdbufstat.py -t -s \",\" -o /tmp/t.log\n")
|
sys.stderr.write("\tdbufstat.py -t -s \",\" -o /tmp/t.log\n")
|
||||||
|
@ -167,6 +172,7 @@ def usage():
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def prettynum(sz, scale, num=0):
|
def prettynum(sz, scale, num=0):
|
||||||
global raw
|
global raw
|
||||||
|
|
||||||
|
@ -194,6 +200,7 @@ def prettynum(sz, scale, num=0):
|
||||||
else:
|
else:
|
||||||
return "%*d%s" % (sz - 1, num, suffix[index])
|
return "%*d%s" % (sz - 1, num, suffix[index])
|
||||||
|
|
||||||
|
|
||||||
def print_values(v):
|
def print_values(v):
|
||||||
global hdr
|
global hdr
|
||||||
global sep
|
global sep
|
||||||
|
@ -207,6 +214,7 @@ def print_values(v):
|
||||||
if e.errno == errno.EPIPE:
|
if e.errno == errno.EPIPE:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def print_header():
|
def print_header():
|
||||||
global hdr
|
global hdr
|
||||||
global sep
|
global sep
|
||||||
|
@ -219,52 +227,82 @@ def print_header():
|
||||||
if e.errno == errno.EPIPE:
|
if e.errno == errno.EPIPE:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def get_typestring(t):
|
def get_typestring(t):
|
||||||
type_strings = ["DMU_OT_NONE",
|
type_strings = ["DMU_OT_NONE",
|
||||||
# general:
|
# general:
|
||||||
"DMU_OT_OBJECT_DIRECTORY", "DMU_OT_OBJECT_ARRAY",
|
"DMU_OT_OBJECT_DIRECTORY",
|
||||||
"DMU_OT_PACKED_NVLIST", "DMU_OT_PACKED_NVLIST_SIZE",
|
"DMU_OT_OBJECT_ARRAY",
|
||||||
"DMU_OT_BPOBJ", "DMU_OT_BPOBJ_HDR",
|
"DMU_OT_PACKED_NVLIST",
|
||||||
# spa:
|
"DMU_OT_PACKED_NVLIST_SIZE",
|
||||||
"DMU_OT_SPACE_MAP_HEADER", "DMU_OT_SPACE_MAP",
|
"DMU_OT_BPOBJ",
|
||||||
# zil:
|
"DMU_OT_BPOBJ_HDR",
|
||||||
"DMU_OT_INTENT_LOG",
|
# spa:
|
||||||
# dmu:
|
"DMU_OT_SPACE_MAP_HEADER",
|
||||||
"DMU_OT_DNODE", "DMU_OT_OBJSET",
|
"DMU_OT_SPACE_MAP",
|
||||||
# dsl:
|
# zil:
|
||||||
"DMU_OT_DSL_DIR", "DMU_OT_DSL_DIR_CHILD_MAP",
|
"DMU_OT_INTENT_LOG",
|
||||||
"DMU_OT_DSL_DS_SNAP_MAP", "DMU_OT_DSL_PROPS",
|
# dmu:
|
||||||
"DMU_OT_DSL_DATASET",
|
"DMU_OT_DNODE",
|
||||||
# zpl:
|
"DMU_OT_OBJSET",
|
||||||
"DMU_OT_ZNODE", "DMU_OT_OLDACL", "DMU_OT_PLAIN_FILE_CONTENTS",
|
# dsl:
|
||||||
"DMU_OT_DIRECTORY_CONTENTS", "DMU_OT_MASTER_NODE",
|
"DMU_OT_DSL_DIR",
|
||||||
"DMU_OT_UNLINKED_SET",
|
"DMU_OT_DSL_DIR_CHILD_MAP",
|
||||||
# zvol:
|
"DMU_OT_DSL_DS_SNAP_MAP",
|
||||||
"DMU_OT_ZVOL", "DMU_OT_ZVOL_PROP",
|
"DMU_OT_DSL_PROPS",
|
||||||
# other; for testing only!
|
"DMU_OT_DSL_DATASET",
|
||||||
"DMU_OT_PLAIN_OTHER", "DMU_OT_UINT64_OTHER", "DMU_OT_ZAP_OTHER",
|
# zpl:
|
||||||
# new object types:
|
"DMU_OT_ZNODE",
|
||||||
"DMU_OT_ERROR_LOG", "DMU_OT_SPA_HISTORY",
|
"DMU_OT_OLDACL",
|
||||||
"DMU_OT_SPA_HISTORY_OFFSETS", "DMU_OT_POOL_PROPS",
|
"DMU_OT_PLAIN_FILE_CONTENTS",
|
||||||
"DMU_OT_DSL_PERMS", "DMU_OT_ACL", "DMU_OT_SYSACL",
|
"DMU_OT_DIRECTORY_CONTENTS",
|
||||||
"DMU_OT_FUID", "DMU_OT_FUID_SIZE", "DMU_OT_NEXT_CLONES",
|
"DMU_OT_MASTER_NODE",
|
||||||
"DMU_OT_SCAN_QUEUE", "DMU_OT_USERGROUP_USED",
|
"DMU_OT_UNLINKED_SET",
|
||||||
"DMU_OT_USERGROUP_QUOTA", "DMU_OT_USERREFS", "DMU_OT_DDT_ZAP",
|
# zvol:
|
||||||
"DMU_OT_DDT_STATS", "DMU_OT_SA", "DMU_OT_SA_MASTER_NODE",
|
"DMU_OT_ZVOL",
|
||||||
"DMU_OT_SA_ATTR_REGISTRATION", "DMU_OT_SA_ATTR_LAYOUTS",
|
"DMU_OT_ZVOL_PROP",
|
||||||
"DMU_OT_SCAN_XLATE", "DMU_OT_DEDUP", "DMU_OT_DEADLIST",
|
# other; for testing only!
|
||||||
"DMU_OT_DEADLIST_HDR", "DMU_OT_DSL_CLONES",
|
"DMU_OT_PLAIN_OTHER",
|
||||||
"DMU_OT_BPOBJ_SUBOBJ"]
|
"DMU_OT_UINT64_OTHER",
|
||||||
|
"DMU_OT_ZAP_OTHER",
|
||||||
|
# new object types:
|
||||||
|
"DMU_OT_ERROR_LOG",
|
||||||
|
"DMU_OT_SPA_HISTORY",
|
||||||
|
"DMU_OT_SPA_HISTORY_OFFSETS",
|
||||||
|
"DMU_OT_POOL_PROPS",
|
||||||
|
"DMU_OT_DSL_PERMS",
|
||||||
|
"DMU_OT_ACL",
|
||||||
|
"DMU_OT_SYSACL",
|
||||||
|
"DMU_OT_FUID",
|
||||||
|
"DMU_OT_FUID_SIZE",
|
||||||
|
"DMU_OT_NEXT_CLONES",
|
||||||
|
"DMU_OT_SCAN_QUEUE",
|
||||||
|
"DMU_OT_USERGROUP_USED",
|
||||||
|
"DMU_OT_USERGROUP_QUOTA",
|
||||||
|
"DMU_OT_USERREFS",
|
||||||
|
"DMU_OT_DDT_ZAP",
|
||||||
|
"DMU_OT_DDT_STATS",
|
||||||
|
"DMU_OT_SA",
|
||||||
|
"DMU_OT_SA_MASTER_NODE",
|
||||||
|
"DMU_OT_SA_ATTR_REGISTRATION",
|
||||||
|
"DMU_OT_SA_ATTR_LAYOUTS",
|
||||||
|
"DMU_OT_SCAN_XLATE",
|
||||||
|
"DMU_OT_DEDUP",
|
||||||
|
"DMU_OT_DEADLIST",
|
||||||
|
"DMU_OT_DEADLIST_HDR",
|
||||||
|
"DMU_OT_DSL_CLONES",
|
||||||
|
"DMU_OT_BPOBJ_SUBOBJ"]
|
||||||
|
|
||||||
# If "-rr" option is used, don't convert to string representation
|
# If "-rr" option is used, don't convert to string representation
|
||||||
if raw > 1:
|
if raw > 1:
|
||||||
return "%i" % t
|
return "%i" % t
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return type_strings[t];
|
return type_strings[t]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "%i" % t
|
return "%i" % t
|
||||||
|
|
||||||
|
|
||||||
def get_compstring(c):
|
def get_compstring(c):
|
||||||
comp_strings = ["ZIO_COMPRESS_INHERIT", "ZIO_COMPRESS_ON",
|
comp_strings = ["ZIO_COMPRESS_INHERIT", "ZIO_COMPRESS_ON",
|
||||||
"ZIO_COMPRESS_OFF", "ZIO_COMPRESS_LZJB",
|
"ZIO_COMPRESS_OFF", "ZIO_COMPRESS_LZJB",
|
||||||
|
@ -281,10 +319,11 @@ def get_compstring(c):
|
||||||
return "%i" % c
|
return "%i" % c
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return comp_strings[c];
|
return comp_strings[c]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "%i" % c
|
return "%i" % c
|
||||||
|
|
||||||
|
|
||||||
def parse_line(line, labels):
|
def parse_line(line, labels):
|
||||||
global hdr
|
global hdr
|
||||||
|
|
||||||
|
@ -307,14 +346,15 @@ def parse_line(line, labels):
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|
||||||
def update_dict(d, k, line, labels):
|
def update_dict(d, k, line, labels):
|
||||||
pool = line[labels['pool']]
|
pool = line[labels['pool']]
|
||||||
objset = line[labels['objset']]
|
objset = line[labels['objset']]
|
||||||
key = line[labels[k]]
|
key = line[labels[k]]
|
||||||
|
|
||||||
dbsize = int(line[labels['dbsize']])
|
dbsize = int(line[labels['dbsize']])
|
||||||
blkid = int(line[labels['blkid']])
|
blkid = int(line[labels['blkid']])
|
||||||
level = int(line[labels['level']])
|
level = int(line[labels['level']])
|
||||||
|
|
||||||
if pool not in d:
|
if pool not in d:
|
||||||
d[pool] = dict()
|
d[pool] = dict()
|
||||||
|
@ -323,12 +363,12 @@ def update_dict(d, k, line, labels):
|
||||||
d[pool][objset] = dict()
|
d[pool][objset] = dict()
|
||||||
|
|
||||||
if key not in d[pool][objset]:
|
if key not in d[pool][objset]:
|
||||||
d[pool][objset][key] = parse_line(line, labels)
|
d[pool][objset][key] = parse_line(line, labels)
|
||||||
d[pool][objset][key]['bonus'] = 0
|
d[pool][objset][key]['bonus'] = 0
|
||||||
d[pool][objset][key]['cached'] = 0
|
d[pool][objset][key]['cached'] = 0
|
||||||
d[pool][objset][key]['direct'] = 0
|
d[pool][objset][key]['direct'] = 0
|
||||||
d[pool][objset][key]['indirect'] = 0
|
d[pool][objset][key]['indirect'] = 0
|
||||||
d[pool][objset][key]['spill'] = 0
|
d[pool][objset][key]['spill'] = 0
|
||||||
|
|
||||||
d[pool][objset][key]['cached'] += dbsize
|
d[pool][objset][key]['cached'] += dbsize
|
||||||
|
|
||||||
|
@ -404,6 +444,7 @@ def buffers_print_all(filehandle):
|
||||||
for line in filehandle:
|
for line in filehandle:
|
||||||
print_values(parse_line(line.split(), labels))
|
print_values(parse_line(line.split(), labels))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global hdr
|
global hdr
|
||||||
global sep
|
global sep
|
||||||
|
@ -474,10 +515,10 @@ def main():
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if bflag:
|
if bflag:
|
||||||
hdr = bxhdr if xflag else bhdr
|
hdr = bxhdr if xflag else bhdr
|
||||||
elif tflag:
|
elif tflag:
|
||||||
hdr = txhdr if xflag else thdr
|
hdr = txhdr if xflag else thdr
|
||||||
else: # Even if dflag is False, it's the default if none set
|
else: # Even if dflag is False, it's the default if none set
|
||||||
dflag = True
|
dflag = True
|
||||||
hdr = dxhdr if xflag else dhdr
|
hdr = dxhdr if xflag else dhdr
|
||||||
|
|
||||||
|
@ -499,7 +540,8 @@ def main():
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if len(incompat) > 0:
|
if len(incompat) > 0:
|
||||||
sys.stderr.write("Incompatible field specified! -- %s\n" % incompat)
|
sys.stderr.write("Incompatible field specified! -- %s\n" %
|
||||||
|
incompat)
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
if ofile:
|
if ofile:
|
||||||
|
@ -507,8 +549,8 @@ def main():
|
||||||
tmp = open(ofile, "w")
|
tmp = open(ofile, "w")
|
||||||
sys.stdout = tmp
|
sys.stdout = tmp
|
||||||
|
|
||||||
except:
|
except IOError:
|
||||||
sys.stderr.write("Cannot open %s for writing\n", ofile)
|
sys.stderr.write("Cannot open %s for writing\n" % ofile)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not ifile:
|
if not ifile:
|
||||||
|
|
Loading…
Reference in New Issue