diff options
author | Matthew Ahrens <[email protected]> | 2020-06-26 18:05:28 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-26 18:05:28 -0700 |
commit | 7b232e93548a187beb5490314dad181f9ce6b17c (patch) | |
tree | 8776bbb46c8d5200144c6ba77163fa18e79fb4be /cmd | |
parent | bfcbec6f5d8aad60365eaeacff21df92c04c26df (diff) |
arcstat: add 'avail', fix 'free'
The meaning of the `free` field is currently `zfs_arc_sys_free`, which
is the target amount of memory to leave free for the system, and is
constant after booting.
This commit changes the meaning of `free` to arc_free_memory(), the
amount of memory that the ARC considers to be free.
It also adds a new arcstat field `avail`, which tracks
`arc_available_memory()`.
Since `avail` can be negative, it also updates the arcstat script to
pretty-print negative values.
example output:
$ arcstat -f time,miss,arcsz,c,grow,need,free,avail 1
time miss arcsz c grow need free avail
15:03:02 39K 114G 114G 0 0 2.4G 407M
15:03:03 42K 114G 114G 0 0 2.1G 120M
15:03:04 40K 114G 114G 0 0 1.8G -177M
15:03:05 24K 113G 112G 0 0 1.7G -269M
15:03:06 29K 111G 110G 0 0 1.6G -385M
15:03:07 27K 110G 108G 0 0 1.4G -535M
15:03:08 13K 108G 108G 0 0 2.2G 239M
15:03:09 33K 107G 107G 0 0 1.3G -639M
15:03:10 16K 105G 102G 0 0 2.6G 704M
15:03:11 7.2K 102G 102G 0 0 5.1G 3.1G
15:03:12 42K 103G 102G 0 0 4.8G 2.8G
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Pavel Zakharov <[email protected]>
Reviewed-by: Tony Nguyen <[email protected]>
Signed-off-by: Matthew Ahrens <[email protected]>
Closes #10494
Diffstat (limited to 'cmd')
-rwxr-xr-x | cmd/arcstat/arcstat | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/cmd/arcstat/arcstat b/cmd/arcstat/arcstat index df2f62d6b..5ce7e755c 100755 --- a/cmd/arcstat/arcstat +++ b/cmd/arcstat/arcstat @@ -81,6 +81,7 @@ cols = { "mh%": [3, 100, "Metadata hit percentage"], "mm%": [3, 100, "Metadata miss percentage"], "arcsz": [5, 1024, "ARC size"], + "size": [4, 1024, "ARC size"], "c": [4, 1024, "ARC target size"], "mfu": [4, 1000, "MFU list hits per second"], "mru": [4, 1000, "MRU list hits per second"], @@ -101,11 +102,12 @@ cols = { "grow": [4, 1000, "ARC grow disabled"], "need": [4, 1024, "ARC reclaim need"], "free": [4, 1024, "ARC free memory"], + "avail": [5, 1024, "ARC available memory"], } v = {} hdr = ["time", "read", "miss", "miss%", "dmis", "dm%", "pmis", "pm%", "mmis", - "mm%", "arcsz", "c"] + "mm%", "size", "c", "avail"] xhdr = ["time", "mfu", "mru", "mfug", "mrug", "eskip", "mtxmis", "dread", "pread", "read"] sint = 1 # Default interval is 1 second @@ -225,7 +227,7 @@ def prettynum(sz, scale, num=0): elif 0 < num < 1: num = 0 - while num > scale and index < 5: + while abs(num) > scale and index < 5: save = num num = num / scale index += 1 @@ -233,7 +235,7 @@ def prettynum(sz, scale, num=0): if index == 0: return "%*d" % (sz, num) - if (save / scale) < 10: + if abs(save / scale) < 10: return "%*.1f%s" % (sz - 1, num, suffix[index]) else: return "%*d%s" % (sz - 1, num, suffix[index]) @@ -244,11 +246,9 @@ def print_values(): global sep global v - for col in hdr: - sys.stdout.write("%s%s" % ( - prettynum(cols[col][0], cols[col][1], v[col]), - sep - )) + sys.stdout.write(sep.join( + prettynum(cols[col][0], cols[col][1], v[col]) for col in hdr)) + sys.stdout.write("\n") sys.stdout.flush() @@ -257,8 +257,8 @@ def print_header(): global hdr global sep - for col in hdr: - sys.stdout.write("%*s%s" % (cols[col][0], col, sep)) + sys.stdout.write(sep.join("%*s" % (cols[col][0], col) for col in hdr)) + sys.stdout.write("\n") @@ -428,6 +428,7 @@ def calculate(): v["mm%"] = 100 - v["mh%"] if v["mread"] > 0 else 0 v["arcsz"] = cur["size"] + v["size"] = cur["size"] v["c"] = cur["c"] v["mfu"] = d["mfu_hits"] / sint v["mru"] = d["mru_hits"] / sint @@ -449,7 +450,8 @@ def calculate(): v["grow"] = 0 if cur["arc_no_grow"] else 1 v["need"] = cur["arc_need_free"] - v["free"] = cur["arc_sys_free"] + v["free"] = cur["memory_free_bytes"] + v["avail"] = cur["memory_available_bytes"] def main(): |