aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r--tests/zfs-tests/include/libtest.shlib26
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 9898bada9..98ef54e4d 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -4154,18 +4154,36 @@ function ls_xattr # path
esac
}
+function kstat # stat flags?
+{
+ typeset stat=$1
+ typeset flags=${2-"-n"}
+
+ case $(uname) in
+ FreeBSD)
+ sysctl $flags kstat.zfs.misc.$stat
+ ;;
+ Linux)
+ typeset zfs_kstat="/proc/spl/kstat/zfs/$stat"
+ [[ -f "$zfs_kstat" ]] || return 1
+ cat $zfs_kstat
+ ;;
+ *)
+ false
+ ;;
+ esac
+}
+
function get_arcstat # stat
{
typeset stat=$1
case $(uname) in
FreeBSD)
- sysctl -n kstat.zfs.misc.arcstats.$stat
+ kstat arcstats.$stat
;;
Linux)
- typeset zfs_arcstats="/proc/spl/kstat/zfs/arcstats"
- [[ -f "$zfs_arcstats" ]] || return 1
- grep $stat $zfs_arcstats | awk '{print $3}'
+ kstat arcstats | awk "/$stat/ { print \$3 }"
;;
*)
false