mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-13 11:40:25 +03:00
Add/generalize abstraction in arc_summary2
A more generic interface can be used for the abstraction of loading kstats, allowing other platforms to implement the function cleanly. In a similar vein, loading tunables can be abstracted away in order for other platforms to provide their own implementations of this function. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Signed-off-by: Ryan Moeller <ryan@ixsystems.com> Closes #9277
This commit is contained in:
parent
b88ca2acf5
commit
6122948b3b
@ -54,6 +54,7 @@ import errno
|
|||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from decimal import Decimal as D
|
from decimal import Decimal as D
|
||||||
|
|
||||||
|
|
||||||
show_tunable_descriptions = False
|
show_tunable_descriptions = False
|
||||||
alternate_tunable_layout = False
|
alternate_tunable_layout = False
|
||||||
|
|
||||||
@ -76,24 +77,19 @@ def get_Kstat():
|
|||||||
of the same name.
|
of the same name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def load_proc_kstats(fn, namespace):
|
def load_kstats(namespace):
|
||||||
"""Collect information on a specific subsystem of the ARC"""
|
"""Collect information on a specific subsystem of the ARC"""
|
||||||
|
|
||||||
kstats = [line.strip() for line in open(fn)]
|
kstat = 'kstat.zfs.misc.%s.%%s' % namespace
|
||||||
del kstats[0:2]
|
path = '/proc/spl/kstat/zfs/%s' % namespace
|
||||||
for kstat in kstats:
|
with open(path) as f:
|
||||||
kstat = kstat.strip()
|
entries = [line.strip().split() for line in f][2:] # Skip header
|
||||||
name, _, value = kstat.split()
|
return [(kstat % name, D(value)) for name, _, value in entries]
|
||||||
Kstat[namespace + name] = D(value)
|
|
||||||
|
|
||||||
Kstat = {}
|
Kstat = {}
|
||||||
load_proc_kstats('/proc/spl/kstat/zfs/arcstats',
|
Kstat.update(load_kstats('arcstats'))
|
||||||
'kstat.zfs.misc.arcstats.')
|
Kstat.update(load_kstats('zfetchstats'))
|
||||||
load_proc_kstats('/proc/spl/kstat/zfs/zfetchstats',
|
Kstat.update(load_kstats('vdev_cache_stats'))
|
||||||
'kstat.zfs.misc.zfetchstats.')
|
|
||||||
load_proc_kstats('/proc/spl/kstat/zfs/vdev_cache_stats',
|
|
||||||
'kstat.zfs.misc.vdev_cache_stats.')
|
|
||||||
|
|
||||||
return Kstat
|
return Kstat
|
||||||
|
|
||||||
|
|
||||||
@ -921,14 +917,19 @@ def _tunable_summary(Kstat):
|
|||||||
global show_tunable_descriptions
|
global show_tunable_descriptions
|
||||||
global alternate_tunable_layout
|
global alternate_tunable_layout
|
||||||
|
|
||||||
names = os.listdir("/sys/module/zfs/parameters/")
|
def load_tunables():
|
||||||
|
basepath = '/sys/module/zfs/parameters'
|
||||||
values = {}
|
tunables = {}
|
||||||
for name in names:
|
for name in os.listdir(basepath):
|
||||||
with open("/sys/module/zfs/parameters/" + name) as f:
|
if not name:
|
||||||
value = f.read()
|
continue
|
||||||
values[name] = value.strip()
|
path = '%s/%s' % (basepath, name)
|
||||||
|
with open(path) as f:
|
||||||
|
value = f.read()
|
||||||
|
tunables[name] = value.strip()
|
||||||
|
return tunables
|
||||||
|
|
||||||
|
tunables = load_tunables()
|
||||||
descriptions = {}
|
descriptions = {}
|
||||||
|
|
||||||
if show_tunable_descriptions:
|
if show_tunable_descriptions:
|
||||||
@ -966,22 +967,17 @@ def _tunable_summary(Kstat):
|
|||||||
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
||||||
|
|
||||||
sys.stdout.write("ZFS Tunables:\n")
|
sys.stdout.write("ZFS Tunables:\n")
|
||||||
names.sort()
|
|
||||||
|
|
||||||
if alternate_tunable_layout:
|
if alternate_tunable_layout:
|
||||||
fmt = "\t%s=%s\n"
|
fmt = "\t%s=%s\n"
|
||||||
else:
|
else:
|
||||||
fmt = "\t%-50s%s\n"
|
fmt = "\t%-50s%s\n"
|
||||||
|
|
||||||
for name in names:
|
for name in sorted(tunables.keys()):
|
||||||
|
|
||||||
if not name:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if show_tunable_descriptions and name in descriptions:
|
if show_tunable_descriptions and name in descriptions:
|
||||||
sys.stdout.write("\t# %s\n" % descriptions[name])
|
sys.stdout.write("\t# %s\n" % descriptions[name])
|
||||||
|
|
||||||
sys.stdout.write(fmt % (name, values[name]))
|
sys.stdout.write(fmt % (name, tunables[name]))
|
||||||
|
|
||||||
|
|
||||||
unSub = [
|
unSub = [
|
||||||
|
Loading…
Reference in New Issue
Block a user