aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChrist Schlacta <[email protected]>2013-06-06 21:33:01 -0700
committerBrian Behlendorf <[email protected]>2013-06-18 15:43:15 -0700
commitfb02fabf9b8045d6a1ddedf3f79171f69633162d (patch)
tree671f27d97396973fbc0c2b8775587eda8213b233
parent7634cd54db25a69e00aaab6448ad710441bd8e7d (diff)
Modified arcstat.py to run on linux
* Modified kstat_update() to read arcstats from proc. * Fix shebang. * Added Makefile.am entries for arcstat.py Signed-off-by: Brian Behlendorf <[email protected]> Closes #1506
-rw-r--r--cmd/Makefile.am2
-rw-r--r--cmd/arcstat/Makefile.am2
-rwxr-xr-xcmd/arcstat/arcstat.py24
-rw-r--r--configure.ac1
-rw-r--r--rpm/generic/zfs.spec.in1
5 files changed, 10 insertions, 20 deletions
diff --git a/cmd/Makefile.am b/cmd/Makefile.am
index 1a51ddcbc..bad1af63e 100644
--- a/cmd/Makefile.am
+++ b/cmd/Makefile.am
@@ -1,2 +1,2 @@
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest zpios
-SUBDIRS += mount_zfs fsck_zfs zvol_id vdev_id
+SUBDIRS += mount_zfs fsck_zfs zvol_id vdev_id arcstat
diff --git a/cmd/arcstat/Makefile.am b/cmd/arcstat/Makefile.am
new file mode 100644
index 000000000..802b8e1d9
--- /dev/null
+++ b/cmd/arcstat/Makefile.am
@@ -0,0 +1,2 @@
+bin_SCRIPTS = arcstat.py
+EXTRA_DIST = $(bin_SCRIPTS)
diff --git a/cmd/arcstat/arcstat.py b/cmd/arcstat/arcstat.py
index fcfdbb832..e01dd8b4c 100755
--- a/cmd/arcstat/arcstat.py
+++ b/cmd/arcstat/arcstat.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/python
#
# Print out ZFS ARC Statistics exported via kstat(1)
# For a definition of fields, or usage, use arctstat.pl -v
@@ -51,7 +51,6 @@ import re
import copy
from decimal import Decimal
-from subprocess import Popen, PIPE
from signal import signal, SIGINT
cols = {
@@ -149,33 +148,20 @@ def usage():
def kstat_update():
global kstat
- p = Popen("/sbin/sysctl -q 'kstat.zfs.misc.arcstats'", stdin=PIPE,
- stdout=PIPE, stderr=PIPE, shell=True, close_fds=True)
- p.wait()
-
- k = p.communicate()[0].split('\n')
- if p.returncode != 0:
- sys.exit(1)
+ k = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
if not k:
sys.exit(1)
+ del k[0:2]
kstat = {}
for s in k:
if not s:
continue
- s = s.strip()
-
- name, value = s.split(':')
- name = name.strip()
- value = value.strip()
-
- parts = name.split('.')
- n = parts.pop()
-
- kstat[n] = Decimal(value)
+ name, unused, value = s.split()
+ kstat[name] = Decimal(value)
def snap_stats():
diff --git a/configure.ac b/configure.ac
index 13bb5baf7..58e215870 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,7 @@ AC_CONFIG_FILES([
cmd/fsck_zfs/Makefile
cmd/zvol_id/Makefile
cmd/vdev_id/Makefile
+ cmd/arcstat/Makefile
module/Makefile
module/avl/Makefile
module/nvpair/Makefile
diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
index 7ee4ca018..ddbee84a4 100644
--- a/rpm/generic/zfs.spec.in
+++ b/rpm/generic/zfs.spec.in
@@ -123,6 +123,7 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
%doc AUTHORS COPYRIGHT DISCLAIMER
%doc OPENSOLARIS.LICENSE README.markdown
%{_sbindir}/*
+%{_bindir}/*
%{_libdir}/*.so.1*
%{_mandir}/man1/*
%{_mandir}/man5/*