aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/arc_summary
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-07 18:02:35 +0200
committerBrian Behlendorf <[email protected]>2021-04-11 11:57:14 -0700
commit0f2915602e9dc5b0545ba284628d0c14c21e474b (patch)
tree1ac12aba61624d9474cd07321eebb5d5583f5d54 /cmd/arc_summary
parent519aec83f574d5d60b46d716161db2195f0a0ae1 (diff)
arc_summary3: just read /s/m/{mod}/version instead of spawning cat
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Pavel Zakharov <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11859
Diffstat (limited to 'cmd/arc_summary')
-rwxr-xr-xcmd/arc_summary/arc_summary320
1 files changed, 5 insertions, 15 deletions
diff --git a/cmd/arc_summary/arc_summary3 b/cmd/arc_summary/arc_summary3
index 96f7990e1..d6ddd06e7 100755
--- a/cmd/arc_summary/arc_summary3
+++ b/cmd/arc_summary/arc_summary3
@@ -161,21 +161,11 @@ elif sys.platform.startswith('linux'):
# The original arc_summary called /sbin/modinfo/{spl,zfs} to get
# the version information. We switch to /sys/module/{spl,zfs}/version
# to make sure we get what is really loaded in the kernel
- command = ["cat", "/sys/module/{0}/version".format(request)]
- req = request.upper()
-
- # The recommended way to do this is with subprocess.run(). However,
- # some installed versions of Python are < 3.5, so we offer them
- # the option of doing it the old way (for now)
- if 'run' in dir(subprocess):
- info = subprocess.run(command, stdout=subprocess.PIPE,
- universal_newlines=True)
- version = info.stdout.strip()
- else:
- info = subprocess.check_output(command, universal_newlines=True)
- version = info.strip()
-
- return version
+ try:
+ with open("/sys/module/{}/version".format(request)) as f:
+ return f.read().strip()
+ except:
+ return "(unknown)"
def get_descriptions(request):
"""Get the descriptions of the Solaris Porting Layer (SPL) or the