aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/arc_summary
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-12-08 20:20:25 +0000
committerBrian Behlendorf <[email protected]>2020-12-11 10:29:53 -0800
commit695ac5850b8ba9792c038e26051a4991a0d6de8d (patch)
treecc2469948fe5b561b35797b3835ad9c506af0b10 /cmd/arc_summary
parent439dc034e94c99e413430277c81b3c45e0060e51 (diff)
arc_summary3: Handle overflowing value width
Some tunables shown by arc_summary3 have string values that may exceed the normal line length, leaving a negative offset between the name and value fields. The negative space is of course not valid and Python rightly barfs up an exception traceback. Handle an overflowing value field width by ignoring the line length and separating the name from the value by a single space instead. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11270
Diffstat (limited to 'cmd/arc_summary')
-rwxr-xr-xcmd/arc_summary/arc_summary38
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/arc_summary/arc_summary3 b/cmd/arc_summary/arc_summary3
index 61a8e3b3e..96f7990e1 100755
--- a/cmd/arc_summary/arc_summary3
+++ b/cmd/arc_summary/arc_summary3
@@ -387,8 +387,12 @@ def format_raw_line(name, value):
if ARGS.alt:
result = '{0}{1}={2}'.format(INDENT, name, value)
else:
- spc = LINE_LENGTH-(len(INDENT)+len(value))
- result = '{0}{1:<{spc}}{2}'.format(INDENT, name, value, spc=spc)
+ # Right-align the value within the line length if it fits,
+ # otherwise just separate it from the name by a single space.
+ fit = LINE_LENGTH - len(INDENT) - len(name)
+ overflow = len(value) + 1
+ w = max(fit, overflow)
+ result = '{0}{1}{2:>{w}}'.format(INDENT, name, value, w=w)
return result