aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-10-08 12:40:23 -0400
committerGitHub <[email protected]>2020-10-08 09:40:23 -0700
commit73989f4b9ec3b550bdd10ba8ba2ab64b91e4e71b (patch)
tree91d6b1608170bf5bbb4c1d6fdbc593b974384af5 /cmd
parent82b81a2acd92cb43322bc572d2e547b66e456cd9 (diff)
Make dbufstat work on FreeBSD
With procfs_list kstats implemented for FreeBSD, dbufs are now exposed as kstat.zfs.misc.dbufs. On FreeBSD, dbufstats can use the sysctl instead of procfs when no input file has been given. Enable the dbufstats tests on FreeBSD. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11008
Diffstat (limited to 'cmd')
-rwxr-xr-xcmd/dbufstat/dbufstat.in17
1 files changed, 16 insertions, 1 deletions
diff --git a/cmd/dbufstat/dbufstat.in b/cmd/dbufstat/dbufstat.in
index 98eb79057..1d4eb39d7 100755
--- a/cmd/dbufstat/dbufstat.in
+++ b/cmd/dbufstat/dbufstat.in
@@ -113,6 +113,21 @@ 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):
@@ -645,7 +660,7 @@ def main():
sys.exit(1)
if not ifile:
- ifile = '/proc/spl/kstat/zfs/dbufs'
+ ifile = default_ifile()
if ifile is not "-":
try: