aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/arcstat
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2019-11-11 12:24:04 -0500
committerBrian Behlendorf <[email protected]>2019-11-11 09:24:04 -0800
commit2f1ca8a32af1c405fc5735673cc3f24f35465b68 (patch)
tree207bd377d01c8597e89ec402d6b2628e8593d57f /cmd/arcstat
parent6c7023a5326cc999cfaced931ee2498642d5e63f (diff)
Isolate code specific to Linux in cmd/
Use sys.platform to choose the correct implementation of functions and values of variables for the platform being run on. Reword some comments to avoid describing implementation details in the wrong places. Reviewed-by: Kjeld Schouten <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Jorgen Lundman <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #9561
Diffstat (limited to 'cmd/arcstat')
-rwxr-xr-xcmd/arcstat/arcstat40
1 files changed, 21 insertions, 19 deletions
diff --git a/cmd/arcstat/arcstat b/cmd/arcstat/arcstat
index 003499928..7562038d1 100755
--- a/cmd/arcstat/arcstat
+++ b/cmd/arcstat/arcstat
@@ -54,6 +54,7 @@ import copy
from decimal import Decimal
from signal import signal, SIGINT, SIGWINCH, SIG_DFL
+
cols = {
# HDR: [Size, Scale, Description]
"time": [8, -1, "Time"],
@@ -118,6 +119,26 @@ out = None
kstat = None
+if sys.platform.startswith('linux'):
+ def kstat_update():
+ global kstat
+
+ k = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
+
+ if not k:
+ sys.exit(1)
+
+ del k[0:2]
+ kstat = {}
+
+ for s in k:
+ if not s:
+ continue
+
+ name, unused, value = s.split()
+ kstat[name] = Decimal(value)
+
+
def detailed_usage():
sys.stderr.write("%s\n" % cmd)
sys.stderr.write("Field definitions are as follows:\n")
@@ -148,25 +169,6 @@ def usage():
sys.exit(1)
-def kstat_update():
- global kstat
-
- k = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
-
- if not k:
- sys.exit(1)
-
- del k[0:2]
- kstat = {}
-
- for s in k:
- if not s:
- continue
-
- name, unused, value = s.split()
- kstat[name] = Decimal(value)
-
-
def snap_stats():
global cur
global kstat