aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/arcstat/arcstat.py
diff options
context:
space:
mode:
authorIsaac Huang <[email protected]>2014-03-10 23:27:56 -0600
committerBrian Behlendorf <[email protected]>2014-03-12 08:56:12 -0700
commit4e1c9f9c48186f61b5fbe1dd8bc150d48a9b9431 (patch)
tree2716e6049737a4a615064e0ed5aa30e4515c48e9 /cmd/arcstat/arcstat.py
parent4e26f2fccd8935c35017a18b0b5ae90464e6b8fe (diff)
Make arcstat.py default to one header per screen
Today arcstat.py prints one header every hdr_intr (20 by default) lines. It would be more consistent with out utilities like vmstat if hdr_intr defaulted to terminal window size, i.e. one header per screenful of outputs. Signed-off-by: Isaac Huang <[email protected]> Signed-off-by: Prakash Surya <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2183
Diffstat (limited to 'cmd/arcstat/arcstat.py')
-rwxr-xr-xcmd/arcstat/arcstat.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/arcstat/arcstat.py b/cmd/arcstat/arcstat.py
index 8fe1331af..5a0912853 100755
--- a/cmd/arcstat/arcstat.py
+++ b/cmd/arcstat/arcstat.py
@@ -230,11 +230,20 @@ def print_header():
sys.stdout.write("%*s%s" % (cols[col][0], col, sep))
sys.stdout.write("\n")
+def get_terminal_lines():
+ try:
+ import fcntl, termios, struct
+ data = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ, '1234')
+ sz = struct.unpack('hh', data)
+ return sz[0]
+ except:
+ pass
def init():
global sint
global count
global hdr
+ global hdr_intr
global xhdr
global opfile
global sep
@@ -304,6 +313,10 @@ def init():
if xflag:
hdr = xhdr
+ lines = get_terminal_lines()
+ if lines:
+ hdr_intr = lines - 3
+
# check if L2ARC exists
snap_stats()
l2_size = cur.get("l2_size")