summaryrefslogtreecommitdiffstats
path: root/cmd/dbufstat
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/dbufstat')
-rw-r--r--cmd/dbufstat/Makefile.am14
-rwxr-xr-xcmd/dbufstat/dbufstat (renamed from cmd/dbufstat/dbufstat.py)16
2 files changed, 22 insertions, 8 deletions
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)