summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/arc_summary/Makefile.am14
-rwxr-xr-xcmd/arc_summary/arc_summary2 (renamed from cmd/arc_summary/arc_summary.py)14
-rwxr-xr-xcmd/arc_summary/arc_summary3 (renamed from cmd/arc_summary/arc_summary3.py)6
-rw-r--r--cmd/arcstat/Makefile.am14
-rwxr-xr-xcmd/arcstat/arcstat (renamed from cmd/arcstat/arcstat.py)15
-rw-r--r--cmd/dbufstat/Makefile.am14
-rwxr-xr-xcmd/dbufstat/dbufstat (renamed from cmd/dbufstat/dbufstat.py)16
7 files changed, 67 insertions, 26 deletions
diff --git a/cmd/arc_summary/Makefile.am b/cmd/arc_summary/Makefile.am
index ac7b0d48d..a83edffad 100644
--- a/cmd/arc_summary/Makefile.am
+++ b/cmd/arc_summary/Makefile.am
@@ -1 +1,13 @@
-dist_bin_SCRIPTS = arc_summary.py arc_summary3.py
+EXTRA_DIST = arc_summary2 arc_summary3
+
+if USING_PYTHON_2
+dist_bin_SCRIPTS = arc_summary2
+install-exec-hook:
+ mv $(DESTDIR)$(bindir)/arc_summary2 $(DESTDIR)$(bindir)/arc_summary
+endif
+
+if USING_PYTHON_3
+dist_bin_SCRIPTS = arc_summary3
+install-exec-hook:
+ mv $(DESTDIR)$(bindir)/arc_summary3 $(DESTDIR)$(bindir)/arc_summary
+endif
diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary2
index 642c94b69..ab4a3c574 100755
--- a/cmd/arc_summary/arc_summary.py
+++ b/cmd/arc_summary/arc_summary2
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python2
#
# $Id: arc_summary.pl,v 388:e27800740aa2 2011-07-08 02:53:29Z jhell $
#
@@ -35,6 +35,8 @@
# Note some of this code uses older code (eg getopt instead of argparse,
# subprocess.Popen() instead of subprocess.run()) because we need to support
# some very old versions of Python.
+#
+
"""Print statistics on the ZFS Adjustable Replacement Cache (ARC)
Provides basic information on the ARC, its efficiency, the L2ARC (if present),
@@ -1005,7 +1007,7 @@ def zfs_header():
def usage():
"""Print usage information"""
- sys.stdout.write("Usage: arc_summary.py [-h] [-a] [-d] [-p PAGE]\n\n")
+ sys.stdout.write("Usage: arc_summary [-h] [-a] [-d] [-p PAGE]\n\n")
sys.stdout.write("\t -h, --help : "
"Print this help message and exit\n")
sys.stdout.write("\t -a, --alternate : "
@@ -1018,10 +1020,10 @@ def usage():
"should be an integer between 1 and " +
str(len(unSub)) + "\n\n")
sys.stdout.write("Examples:\n")
- sys.stdout.write("\tarc_summary.py -a\n")
- sys.stdout.write("\tarc_summary.py -p 4\n")
- sys.stdout.write("\tarc_summary.py -ad\n")
- sys.stdout.write("\tarc_summary.py --page=2\n")
+ sys.stdout.write("\tarc_summary -a\n")
+ sys.stdout.write("\tarc_summary -p 4\n")
+ sys.stdout.write("\tarc_summary -ad\n")
+ sys.stdout.write("\tarc_summary --page=2\n")
def main():
diff --git a/cmd/arc_summary/arc_summary3.py b/cmd/arc_summary/arc_summary3
index e70f2a35e..e67cd90f7 100755
--- a/cmd/arc_summary/arc_summary3.py
+++ b/cmd/arc_summary/arc_summary3
@@ -346,7 +346,7 @@ def get_version(request):
error_msg = '(ERROR: "{0}" requested)'.format(request)
return error_msg
- # The original arc_summary.py called /sbin/modinfo/{spl,zfs} to get
+ # 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)]
@@ -374,7 +374,7 @@ def print_header():
"""
# datetime is now recommended over time but we keep the exact formatting
- # from the older version of arc_summary.py in case there are scripts
+ # from the older version of arc_summary in case there are scripts
# that expect it in this way
daydate = time.strftime(DATE_FORMAT)
spc_date = LINE_LENGTH-len(daydate)
@@ -586,7 +586,7 @@ def section_archits(kstats_dict):
# For some reason, anon_hits can turn negative, which is weird. Until we
# have figured out why this happens, we just hide the problem, following
- # the behavior of the original arc_summary.py
+ # the behavior of the original arc_summary.
if anon_hits >= 0:
prt_i2('Anonymously used:',
f_perc(anon_hits, arc_stats['hits']), f_hits(anon_hits))
diff --git a/cmd/arcstat/Makefile.am b/cmd/arcstat/Makefile.am
index 8987b2414..462e9a619 100644
--- a/cmd/arcstat/Makefile.am
+++ b/cmd/arcstat/Makefile.am
@@ -1 +1,13 @@
-dist_bin_SCRIPTS = arcstat.py
+dist_bin_SCRIPTS = arcstat
+
+#
+# The arcstat script is compatibile with both Python 2.6 and 3.4.
+# As such the python 3 shebang can be replaced at install time when
+# targeting a python 2 system. This allows us to maintain a single
+# version of the source.
+#
+if USING_PYTHON_2
+install-exec-hook:
+ sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
+ $(DESTDIR)$(bindir)/arcstat
+endif
diff --git a/cmd/arcstat/arcstat.py b/cmd/arcstat/arcstat
index a2c52ddb3..57a2d621f 100755
--- a/cmd/arcstat/arcstat.py
+++ b/cmd/arcstat/arcstat
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# Print out ZFS ARC Statistics exported via kstat(1)
# For a definition of fields, or usage, use arctstat.pl -v
@@ -42,7 +42,8 @@
# @hdr is the array of fields that needs to be printed, so we
# just iterate over this array and print the values using our pretty printer.
#
-
+# This script must remain compatible with Python 2.6+ and Python 3.4+.
+#
import sys
import time
@@ -109,7 +110,7 @@ opfile = None
sep = " " # Default separator is 2 spaces
version = "0.4"
l2exist = False
-cmd = ("Usage: arcstat.py [-hvx] [-f fields] [-o file] [-s string] [interval "
+cmd = ("Usage: arcstat [-hvx] [-f fields] [-o file] [-s string] [interval "
"[count]]\n")
cur = {}
d = {}
@@ -138,10 +139,10 @@ def usage():
sys.stderr.write("\t -s : Override default field separator with custom "
"character or string\n")
sys.stderr.write("\nExamples:\n")
- sys.stderr.write("\tarcstat.py -o /tmp/a.log 2 10\n")
- sys.stderr.write("\tarcstat.py -s \",\" -o /tmp/a.log 2 10\n")
- sys.stderr.write("\tarcstat.py -v\n")
- sys.stderr.write("\tarcstat.py -f time,hit%,dh%,ph%,mh% 1\n")
+ sys.stderr.write("\tarcstat -o /tmp/a.log 2 10\n")
+ sys.stderr.write("\tarcstat -s \",\" -o /tmp/a.log 2 10\n")
+ sys.stderr.write("\tarcstat -v\n")
+ sys.stderr.write("\tarcstat -f time,hit%,dh%,ph%,mh% 1\n")
sys.stderr.write("\n")
sys.exit(1)
diff --git a/cmd/dbufstat/Makefile.am b/cmd/dbufstat/Makefile.am
index 19bffb020..968a76077 100644
--- a/cmd/dbufstat/Makefile.am
+++ b/cmd/dbufstat/Makefile.am
@@ -1 +1,13 @@
-dist_bin_SCRIPTS = dbufstat.py
+dist_bin_SCRIPTS = dbufstat
+
+#
+# The dbufstat script is compatibile with both Python 2.6 and 3.4.
+# As such the python 3 shebang can be replaced at install time when
+# targeting a python 2 system. This allows us to maintain a single
+# version of the source.
+#
+if USING_PYTHON_2
+install-exec-hook:
+ sed --in-place 's|^#!/usr/bin/python3|#!/usr/bin/python2|' \
+ $(DESTDIR)$(bindir)/dbufstat
+endif
diff --git a/cmd/dbufstat/dbufstat.py b/cmd/dbufstat/dbufstat
index 5e2217a54..e6c947fbc 100755
--- a/cmd/dbufstat/dbufstat.py
+++ b/cmd/dbufstat/dbufstat
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# Print out statistics for all cached dmu buffers. This information
# is available through the dbufs kstat and may be post-processed as
@@ -27,6 +27,8 @@
# Copyright (C) 2013 Lawrence Livermore National Security, LLC.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
#
+# This script must remain compatible with Python 2.6+ and Python 3.4+.
+#
import sys
import getopt
@@ -106,7 +108,7 @@ cols = {
hdr = None
xhdr = None
sep = " " # Default separator is 2 spaces
-cmd = ("Usage: dbufstat.py [-bdhnrtvx] [-i file] [-f fields] [-o file] "
+cmd = ("Usage: dbufstat [-bdhnrtvx] [-i file] [-f fields] [-o file] "
"[-s string] [-F filter]\n")
raw = 0
@@ -167,11 +169,11 @@ def usage():
"character or string\n")
sys.stderr.write("\t -F : Filter output by value or regex\n")
sys.stderr.write("\nExamples:\n")
- sys.stderr.write("\tdbufstat.py -d -o /tmp/d.log\n")
- sys.stderr.write("\tdbufstat.py -t -s \",\" -o /tmp/t.log\n")
- sys.stderr.write("\tdbufstat.py -v\n")
- sys.stderr.write("\tdbufstat.py -d -f pool,object,objset,dsize,cached\n")
- sys.stderr.write("\tdbufstat.py -bx -F dbc=1,objset=54,pool=testpool\n")
+ sys.stderr.write("\tdbufstat -d -o /tmp/d.log\n")
+ sys.stderr.write("\tdbufstat -t -s \",\" -o /tmp/t.log\n")
+ sys.stderr.write("\tdbufstat -v\n")
+ sys.stderr.write("\tdbufstat -d -f pool,object,objset,dsize,cached\n")
+ sys.stderr.write("\tdbufstat -bx -F dbc=1,objset=54,pool=testpool\n")
sys.stderr.write("\n")
sys.exit(1)