mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-25 18:59:33 +03:00
Replace sysctl summary with tunables summary.
The original script displayed tunable parameters using sysctl calls. This patch modifies this by displaying tunable parameters found in /sys/modules/zfs/parameters/. modinfo calls are used to capture descriptions. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov> Signed-off-by: Ned Bass <bass6@llnl.gov>
This commit is contained in:
parent
65dc685a1d
commit
a644585549
@ -46,14 +46,14 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import getopt
|
import getopt
|
||||||
import re
|
import re
|
||||||
|
from os import listdir
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from decimal import Decimal as D
|
from decimal import Decimal as D
|
||||||
|
|
||||||
|
|
||||||
usetunable = True
|
usetunable = True
|
||||||
show_sysctl_descriptions = False
|
show_tunable_descriptions = False
|
||||||
alternate_sysctl_layout = False
|
alternate_tunable_layout = False
|
||||||
kstat_pobj = re.compile("^([^:]+):\s+(.+)\s*$", flags=re.M)
|
kstat_pobj = re.compile("^([^:]+):\s+(.+)\s*$", flags=re.M)
|
||||||
|
|
||||||
|
|
||||||
@ -1016,70 +1016,59 @@ def _vdev_summary(Kstat):
|
|||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
def get_systl_summary(Kstat):
|
def _tunable_summary(Kstat):
|
||||||
output = {}
|
global show_tunable_descriptions
|
||||||
return output
|
global alternate_tunable_layout
|
||||||
|
|
||||||
|
names = listdir("/sys/module/zfs/parameters/")
|
||||||
|
|
||||||
def _sysctl_summary(Kstat):
|
values = {}
|
||||||
global show_sysctl_descriptions
|
for name in names:
|
||||||
global alternate_sysctl_layout
|
with open("/sys/module/zfs/parameters/" + name) as f: value = f.read()
|
||||||
|
values[name] = value.strip()
|
||||||
|
|
||||||
Tunable = [
|
descriptions = {}
|
||||||
"kern.maxusers",
|
|
||||||
"vm.kmem_size",
|
|
||||||
"vm.kmem_size_scale",
|
|
||||||
"vm.kmem_size_min",
|
|
||||||
"vm.kmem_size_max",
|
|
||||||
"vfs.zfs"
|
|
||||||
]
|
|
||||||
|
|
||||||
if not usetunable:
|
if show_tunable_descriptions:
|
||||||
return
|
try:
|
||||||
|
command = ["/sbin/modinfo", "zfs", "-0"]
|
||||||
|
p = Popen(command, stdin=PIPE, stdout=PIPE,
|
||||||
|
stderr=PIPE, shell=False, close_fds=True)
|
||||||
|
p.wait()
|
||||||
|
|
||||||
sysctl_descriptions = {}
|
description_list = p.communicate()[0].strip().split('\0')
|
||||||
if show_sysctl_descriptions:
|
|
||||||
tunables = " ".join(str(x) for x in Tunable)
|
|
||||||
p = Popen("/sbin/sysctl -qde %s" % tunables, stdin=PIPE,
|
|
||||||
stdout=PIPE, stderr=PIPE, shell=True, close_fds=True)
|
|
||||||
p.wait()
|
|
||||||
|
|
||||||
descriptions = p.communicate()[0].split('\n')
|
if p.returncode == 0:
|
||||||
if p.returncode != 0:
|
for tunable in description_list:
|
||||||
sys.exit(1)
|
if tunable[0:5] == 'parm:':
|
||||||
|
tunable = tunable[5:].strip()
|
||||||
|
name, description = tunable.split(':', 1)
|
||||||
|
if not description:
|
||||||
|
description = "Description unavailable"
|
||||||
|
descriptions[name] = description
|
||||||
|
else:
|
||||||
|
sys.stderr.write("%s: '%s' exited with code %i\n" %
|
||||||
|
(sys.argv[0], command[0], p.returncode))
|
||||||
|
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
||||||
|
except OSError as e:
|
||||||
|
sys.stderr.write("%s: Cannot run '%s': %s\n" %
|
||||||
|
(sys.argv[0], command[0], e.strerror))
|
||||||
|
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
||||||
|
|
||||||
for tunable in descriptions:
|
sys.stdout.write("ZFS Tunable:\n")
|
||||||
if not tunable:
|
for name in names:
|
||||||
continue
|
if not name:
|
||||||
tunable = tunable.strip()
|
|
||||||
name, description = tunable.split('=')[:2]
|
|
||||||
name = name.strip()
|
|
||||||
description = description.strip()
|
|
||||||
if not description:
|
|
||||||
description = "Description unavailable"
|
|
||||||
sysctl_descriptions[name] = description
|
|
||||||
|
|
||||||
tunables = " ".join(str(x) for x in Tunable)
|
|
||||||
p = Popen("/sbin/sysctl -qe %s" % tunables, stdin=PIPE,
|
|
||||||
stdout=PIPE, stderr=PIPE, shell=True, close_fds=True)
|
|
||||||
p.wait()
|
|
||||||
|
|
||||||
zfs_tunables = p.communicate()[0].split('\n')
|
|
||||||
if p.returncode != 0:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
sys.stdout.write("ZFS Tunable (sysctl):\n")
|
|
||||||
for tunable in zfs_tunables:
|
|
||||||
if not tunable:
|
|
||||||
continue
|
continue
|
||||||
tunable = tunable.strip()
|
|
||||||
name, value = tunable.split("=")[0:2]
|
format = "\t%-50s%s\n"
|
||||||
name = name.strip()
|
if alternate_tunable_layout:
|
||||||
value = D(value.strip())
|
format = "\t%s=%s\n"
|
||||||
format = "\t%s=%d\n" if alternate_sysctl_layout else "\t%-40s%d\n"
|
|
||||||
if show_sysctl_descriptions:
|
if show_tunable_descriptions and descriptions.has_key(name):
|
||||||
sys.stdout.write("\t\# %s\n" % sysctl_descriptions[name])
|
sys.stdout.write("\t# %s\n" % descriptions[name])
|
||||||
sys.stdout.write(format % (name, value))
|
|
||||||
|
sys.stdout.write(format % (name, values[name]))
|
||||||
|
|
||||||
|
|
||||||
unSub = [
|
unSub = [
|
||||||
_arc_summary,
|
_arc_summary,
|
||||||
@ -1087,8 +1076,10 @@ unSub = [
|
|||||||
_l2arc_summary,
|
_l2arc_summary,
|
||||||
_dmu_summary,
|
_dmu_summary,
|
||||||
_vdev_summary,
|
_vdev_summary,
|
||||||
|
_tunable_summary
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def zfs_header():
|
def zfs_header():
|
||||||
daydate = time.strftime("%a %b %d %H:%M:%S %Y")
|
daydate = time.strftime("%a %b %d %H:%M:%S %Y")
|
||||||
|
|
||||||
@ -1116,8 +1107,8 @@ def usage():
|
|||||||
sys.stdout.write("\tarc_summary.py --page=2\n")
|
sys.stdout.write("\tarc_summary.py --page=2\n")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global show_sysctl_descriptions
|
global show_tunable_descriptions
|
||||||
global alternate_sysctl_layout
|
global alternate_tunable_layout
|
||||||
|
|
||||||
opts, args = getopt.getopt(
|
opts, args = getopt.getopt(
|
||||||
sys.argv[1:], "adp:h", ["alternate", "description", "page=", "help"]
|
sys.argv[1:], "adp:h", ["alternate", "description", "page=", "help"]
|
||||||
@ -1137,8 +1128,8 @@ def main():
|
|||||||
|
|
||||||
Kstat = get_Kstat()
|
Kstat = get_Kstat()
|
||||||
|
|
||||||
alternate_sysctl_layout = 'a' in args
|
alternate_tunable_layout = 'a' in args
|
||||||
show_sysctl_descriptions = 'd' in args
|
show_tunable_descriptions = 'd' in args
|
||||||
|
|
||||||
pages = []
|
pages = []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user