mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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 <kjeld@schouten-lebbing.nl> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Ryan Moeller <ryan@ixsystems.com> Closes #9561
This commit is contained in:
committed by
Brian Behlendorf
parent
6c7023a532
commit
2f1ca8a32a
+21
-19
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user