]> git.proxmox.com Git - mirror_zfs.git/blobdiff - cmd/dbufstat/dbufstat.in
Replace config/config.awk with simple sed invocation
[mirror_zfs.git] / cmd / dbufstat / dbufstat.in
index 95749bd80ed648661bb97c8429e66dff5c6272b0..b716a0c9749b0a5df2dacf9c268b6c8fe5336aa1 100755 (executable)
@@ -27,7 +27,7 @@
 # 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+.
+# This script must remain compatible with and Python 3.6+.
 #
 
 import sys
@@ -113,10 +113,25 @@ cmd = ("Usage: dbufstat [-bdhnrtvx] [-i file] [-f fields] [-o file] "
 raw = 0
 
 
+if sys.platform.startswith("freebsd"):
+    import io
+    # Requires py-sysctl on FreeBSD
+    import sysctl
+
+    def default_ifile():
+        dbufs = sysctl.filter("kstat.zfs.misc.dbufs")[0].value
+        sys.stdin = io.StringIO(dbufs)
+        return "-"
+
+elif sys.platform.startswith("linux"):
+    def default_ifile():
+        return "/proc/spl/kstat/zfs/dbufs"
+
+
 def print_incompat_helper(incompat):
     cnt = 0
     for key in sorted(incompat):
-        if cnt is 0:
+        if cnt == 0:
             sys.stderr.write("\t")
         elif cnt > 8:
             sys.stderr.write(",\n\t")
@@ -343,7 +358,7 @@ def get_compstring(c):
                     "ZIO_COMPRESS_GZIP_6",  "ZIO_COMPRESS_GZIP_7",
                     "ZIO_COMPRESS_GZIP_8",  "ZIO_COMPRESS_GZIP_9",
                     "ZIO_COMPRESS_ZLE",     "ZIO_COMPRESS_LZ4",
-                    "ZIO_COMPRESS_FUNCTION"]
+                    "ZIO_COMPRESS_ZSTD",    "ZIO_COMPRESS_FUNCTION"]
 
     # If "-rr" option is used, don't convert to string representation
     if raw > 1:
@@ -645,9 +660,9 @@ def main():
             sys.exit(1)
 
     if not ifile:
-        ifile = '/proc/spl/kstat/zfs/dbufs'
+        ifile = default_ifile()
 
-    if ifile is not "-":
+    if ifile != "-":
         try:
             tmp = open(ifile, "r")
             sys.stdin = tmp