Skip to content

Commit

Permalink
Make arcstat.py default to one header per screen
Browse files Browse the repository at this point in the history
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 <he.huang@intel.com>
Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #2183
  • Loading branch information
huangheintel authored and behlendorf committed Mar 12, 2014
1 parent 4e26f2f commit 4e1c9f9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/arcstat/arcstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4e1c9f9

Please sign in to comment.