mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
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 <behlendorf1@llnl.gov> Closes #1506
This commit is contained in:
parent
7634cd54db
commit
fb02fabf9b
@ -1,2 +1,2 @@
|
|||||||
SUBDIRS = zfs zpool zdb zhack zinject zstreamdump ztest zpios
|
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
|
||||||
|
2
cmd/arcstat/Makefile.am
Normal file
2
cmd/arcstat/Makefile.am
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
bin_SCRIPTS = arcstat.py
|
||||||
|
EXTRA_DIST = $(bin_SCRIPTS)
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/bin/python
|
#!/usr/bin/python
|
||||||
#
|
#
|
||||||
# Print out ZFS ARC Statistics exported via kstat(1)
|
# Print out ZFS ARC Statistics exported via kstat(1)
|
||||||
# For a definition of fields, or usage, use arctstat.pl -v
|
# For a definition of fields, or usage, use arctstat.pl -v
|
||||||
@ -51,7 +51,6 @@ import re
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from subprocess import Popen, PIPE
|
|
||||||
from signal import signal, SIGINT
|
from signal import signal, SIGINT
|
||||||
|
|
||||||
cols = {
|
cols = {
|
||||||
@ -149,33 +148,20 @@ def usage():
|
|||||||
def kstat_update():
|
def kstat_update():
|
||||||
global kstat
|
global kstat
|
||||||
|
|
||||||
p = Popen("/sbin/sysctl -q 'kstat.zfs.misc.arcstats'", stdin=PIPE,
|
k = [line.strip() for line in open('/proc/spl/kstat/zfs/arcstats')]
|
||||||
stdout=PIPE, stderr=PIPE, shell=True, close_fds=True)
|
|
||||||
p.wait()
|
|
||||||
|
|
||||||
k = p.communicate()[0].split('\n')
|
|
||||||
if p.returncode != 0:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if not k:
|
if not k:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
del k[0:2]
|
||||||
kstat = {}
|
kstat = {}
|
||||||
|
|
||||||
for s in k:
|
for s in k:
|
||||||
if not s:
|
if not s:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
s = s.strip()
|
name, unused, value = s.split()
|
||||||
|
kstat[name] = Decimal(value)
|
||||||
name, value = s.split(':')
|
|
||||||
name = name.strip()
|
|
||||||
value = value.strip()
|
|
||||||
|
|
||||||
parts = name.split('.')
|
|
||||||
n = parts.pop()
|
|
||||||
|
|
||||||
kstat[n] = Decimal(value)
|
|
||||||
|
|
||||||
|
|
||||||
def snap_stats():
|
def snap_stats():
|
||||||
|
@ -102,6 +102,7 @@ AC_CONFIG_FILES([
|
|||||||
cmd/fsck_zfs/Makefile
|
cmd/fsck_zfs/Makefile
|
||||||
cmd/zvol_id/Makefile
|
cmd/zvol_id/Makefile
|
||||||
cmd/vdev_id/Makefile
|
cmd/vdev_id/Makefile
|
||||||
|
cmd/arcstat/Makefile
|
||||||
module/Makefile
|
module/Makefile
|
||||||
module/avl/Makefile
|
module/avl/Makefile
|
||||||
module/nvpair/Makefile
|
module/nvpair/Makefile
|
||||||
|
@ -123,6 +123,7 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
|
|||||||
%doc AUTHORS COPYRIGHT DISCLAIMER
|
%doc AUTHORS COPYRIGHT DISCLAIMER
|
||||||
%doc OPENSOLARIS.LICENSE README.markdown
|
%doc OPENSOLARIS.LICENSE README.markdown
|
||||||
%{_sbindir}/*
|
%{_sbindir}/*
|
||||||
|
%{_bindir}/*
|
||||||
%{_libdir}/*.so.1*
|
%{_libdir}/*.so.1*
|
||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
%{_mandir}/man5/*
|
%{_mandir}/man5/*
|
||||||
|
Loading…
Reference in New Issue
Block a user