2019-09-12 23:32:32 +03:00
|
|
|
#!/usr/bin/env python2
|
2014-02-11 18:15:50 +04:00
|
|
|
#
|
|
|
|
# $Id: arc_summary.pl,v 388:e27800740aa2 2011-07-08 02:53:29Z jhell $
|
|
|
|
#
|
|
|
|
# Copyright (c) 2008 Ben Rockwood <benr@cuddletech.com>,
|
|
|
|
# Copyright (c) 2010 Martin Matuska <mm@FreeBSD.org>,
|
|
|
|
# Copyright (c) 2010-2011 Jason J. Hellenthal <jhell@DataIX.net>,
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# 1. Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
# SUCH DAMAGE.
|
|
|
|
#
|
|
|
|
# If you are having troubles when using this script from cron(8) please try
|
|
|
|
# adjusting your PATH before reporting problems.
|
2017-11-15 21:28:11 +03:00
|
|
|
#
|
|
|
|
# Note some of this code uses older code (eg getopt instead of argparse,
|
|
|
|
# subprocess.Popen() instead of subprocess.run()) because we need to support
|
|
|
|
# some very old versions of Python.
|
pyzfs: python3 support (build system)
Almost all of the Python code in the respository has been updated
to be compatibile with Python 2.6, Python 3.4, or newer. The only
exceptions are arc_summery3.py which requires Python 3, and pyzfs
which requires at least Python 2.7. This allows us to maintain a
single version of the code and support most default versions of
python. This change does the following:
* Sets the default shebang for all Python scripts to python3. If
only Python 2 is available, then at install time scripts which
are compatible with Python 2 will have their shebangs replaced
with /usr/bin/python. This is done for compatibility until
Python 2 goes end of life. Since only the installed versions
are changed this means Python 3 must be installed on the system
for test-runner when testing in-tree.
* Added --with-python=<2|3|3.4,etc> configure option which sets
the PYTHON environment variable to target a specific python
version. By default the newest installed version of Python
will be used or the preferred distribution version when
creating pacakges.
* Fixed --enable-pyzfs configure checks so they are run when
--enable-pyzfs=check and --enable-pyzfs=yes.
* Enabled pyzfs for Python 3.4 and newer, which is now supported.
* Renamed pyzfs package to python<VERSION>-pyzfs and updated to
install in the appropriate site location. For example, when
building with --with-python=3.4 a python34-pyzfs will be
created which installs in /usr/lib/python3.4/site-packages/.
* Renamed the following python scripts according to the Fedora
guidance for packaging utilities in /bin
- dbufstat.py -> dbufstat
- arcstat.py -> arcstat
- arc_summary.py -> arc_summary
- arc_summary3.py -> arc_summary3
* Updated python-cffi package name. On CentOS 6, CentOS 7, and
Amazon Linux it's called python-cffi, not python2-cffi. For
Python3 it's called python3-cffi or python3x-cffi.
* Install one version of arc_summary. Depending on the version
of Python available install either arc_summary2 or arc_summary3
as arc_summary. The user output is only slightly different.
Reviewed-by: John Ramsden <johnramsden@riseup.net>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8096
2018-10-31 19:22:59 +03:00
|
|
|
#
|
|
|
|
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print statistics on the ZFS Adjustable Replacement Cache (ARC)
|
|
|
|
|
|
|
|
Provides basic information on the ARC, its efficiency, the L2ARC (if present),
|
|
|
|
the Data Management Unit (DMU), Virtual Devices (VDEVs), and tunables. See the
|
|
|
|
in-source documentation and code at
|
|
|
|
https://github.com/zfsonlinux/zfs/blob/master/module/zfs/arc.c for details.
|
|
|
|
"""
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
import getopt
|
2017-11-12 07:27:43 +03:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
2017-12-20 00:19:24 +03:00
|
|
|
import errno
|
2017-11-06 00:11:37 +03:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
from decimal import Decimal as D
|
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
show_tunable_descriptions = False
|
|
|
|
alternate_tunable_layout = False
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
|
2017-12-20 00:19:24 +03:00
|
|
|
def handle_Exception(ex_cls, ex, tb):
|
|
|
|
if ex is IOError:
|
|
|
|
if ex.errno == errno.EPIPE:
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
if ex is KeyboardInterrupt:
|
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
|
sys.excepthook = handle_Exception
|
|
|
|
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
def get_Kstat():
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect information on the ZFS subsystem from the /proc virtual
|
|
|
|
file system. The name "kstat" is a holdover from the Solaris utility
|
|
|
|
of the same name.
|
|
|
|
"""
|
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
def load_kstats(namespace):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect information on a specific subsystem of the ARC"""
|
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
kstat = 'kstat.zfs.misc.%s.%%s' % namespace
|
|
|
|
path = '/proc/spl/kstat/zfs/%s' % namespace
|
|
|
|
with open(path) as f:
|
|
|
|
entries = [line.strip().split() for line in f][2:] # Skip header
|
|
|
|
return [(kstat % name, D(value)) for name, _, value in entries]
|
2014-02-11 19:14:55 +04:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
Kstat = {}
|
2019-09-10 22:17:54 +03:00
|
|
|
Kstat.update(load_kstats('arcstats'))
|
|
|
|
Kstat.update(load_kstats('zfetchstats'))
|
|
|
|
Kstat.update(load_kstats('vdev_cache_stats'))
|
2014-02-11 18:15:50 +04:00
|
|
|
return Kstat
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
|
2017-10-25 09:29:02 +03:00
|
|
|
def fBytes(b=0):
|
|
|
|
"""Return human-readable representation of a byte value in
|
|
|
|
powers of 2 (eg "KiB" for "kibibytes", etc) to two decimal
|
|
|
|
points. Values smaller than one KiB are returned without
|
|
|
|
decimal points.
|
|
|
|
"""
|
|
|
|
|
|
|
|
prefixes = [
|
|
|
|
[2**80, "YiB"], # yobibytes (yotta)
|
|
|
|
[2**70, "ZiB"], # zebibytes (zetta)
|
|
|
|
[2**60, "EiB"], # exbibytes (exa)
|
|
|
|
[2**50, "PiB"], # pebibytes (peta)
|
|
|
|
[2**40, "TiB"], # tebibytes (tera)
|
|
|
|
[2**30, "GiB"], # gibibytes (giga)
|
|
|
|
[2**20, "MiB"], # mebibytes (mega)
|
|
|
|
[2**10, "KiB"]] # kibibytes (kilo)
|
|
|
|
|
|
|
|
if b >= 2**10:
|
|
|
|
|
|
|
|
for limit, unit in prefixes:
|
|
|
|
|
|
|
|
if b >= limit:
|
|
|
|
value = b / limit
|
|
|
|
break
|
|
|
|
|
|
|
|
result = "%0.2f\t%s" % (value, unit)
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
else:
|
2017-10-25 09:29:02 +03:00
|
|
|
|
|
|
|
result = "%d\tBytes" % b
|
|
|
|
|
|
|
|
return result
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
|
2017-11-04 23:33:28 +03:00
|
|
|
def fHits(hits=0):
|
|
|
|
"""Create a human-readable representation of the number of hits.
|
|
|
|
The single-letter symbols used are SI to avoid the confusion caused
|
|
|
|
by the different "short scale" and "long scale" representations in
|
|
|
|
English, which use the same words for different values. See
|
|
|
|
https://en.wikipedia.org/wiki/Names_of_large_numbers and
|
|
|
|
https://physics.nist.gov/cuu/Units/prefixes.html
|
|
|
|
"""
|
|
|
|
|
|
|
|
numbers = [
|
|
|
|
[10**24, 'Y'], # yotta (septillion)
|
|
|
|
[10**21, 'Z'], # zetta (sextillion)
|
|
|
|
[10**18, 'E'], # exa (quintrillion)
|
|
|
|
[10**15, 'P'], # peta (quadrillion)
|
|
|
|
[10**12, 'T'], # tera (trillion)
|
|
|
|
[10**9, 'G'], # giga (billion)
|
|
|
|
[10**6, 'M'], # mega (million)
|
|
|
|
[10**3, 'k']] # kilo (thousand)
|
|
|
|
|
|
|
|
if hits >= 1000:
|
|
|
|
|
|
|
|
for limit, symbol in numbers:
|
|
|
|
|
|
|
|
if hits >= limit:
|
|
|
|
value = hits/limit
|
|
|
|
break
|
|
|
|
|
|
|
|
result = "%0.2f%s" % (value, symbol)
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
else:
|
2017-11-04 23:33:28 +03:00
|
|
|
|
|
|
|
result = "%d" % hits
|
|
|
|
|
|
|
|
return result
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
def fPerc(lVal=0, rVal=0, Decimal=2):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Calculate percentage value and return in human-readable format"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
if rVal > 0:
|
|
|
|
return str("%0." + str(Decimal) + "f") % (100 * (lVal / rVal)) + "%"
|
|
|
|
else:
|
|
|
|
return str("%0." + str(Decimal) + "f") % 100 + "%"
|
|
|
|
|
|
|
|
|
|
|
|
def get_arc_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect general data on the ARC"""
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
output = {}
|
|
|
|
memory_throttle_count = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.memory_throttle_count"
|
|
|
|
]
|
|
|
|
|
|
|
|
if memory_throttle_count > 0:
|
|
|
|
output['health'] = 'THROTTLED'
|
|
|
|
else:
|
|
|
|
output['health'] = 'HEALTHY'
|
|
|
|
|
|
|
|
output['memory_throttle_count'] = fHits(memory_throttle_count)
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Misc.
|
2014-02-11 18:15:50 +04:00
|
|
|
deleted = Kstat["kstat.zfs.misc.arcstats.deleted"]
|
|
|
|
mutex_miss = Kstat["kstat.zfs.misc.arcstats.mutex_miss"]
|
2017-11-19 01:07:04 +03:00
|
|
|
evict_skip = Kstat["kstat.zfs.misc.arcstats.evict_skip"]
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Misc.
|
2014-02-11 18:15:50 +04:00
|
|
|
output["arc_misc"] = {}
|
|
|
|
output["arc_misc"]["deleted"] = fHits(deleted)
|
|
|
|
output["arc_misc"]['mutex_miss'] = fHits(mutex_miss)
|
2017-11-19 01:07:04 +03:00
|
|
|
output["arc_misc"]['evict_skips'] = fHits(evict_skip)
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Sizing
|
2014-02-11 18:15:50 +04:00
|
|
|
arc_size = Kstat["kstat.zfs.misc.arcstats.size"]
|
2017-10-24 00:18:12 +03:00
|
|
|
mru_size = Kstat["kstat.zfs.misc.arcstats.mru_size"]
|
|
|
|
mfu_size = Kstat["kstat.zfs.misc.arcstats.mfu_size"]
|
2018-08-22 19:35:20 +03:00
|
|
|
meta_limit = Kstat["kstat.zfs.misc.arcstats.arc_meta_limit"]
|
|
|
|
meta_size = Kstat["kstat.zfs.misc.arcstats.arc_meta_used"]
|
|
|
|
dnode_limit = Kstat["kstat.zfs.misc.arcstats.arc_dnode_limit"]
|
|
|
|
dnode_size = Kstat["kstat.zfs.misc.arcstats.dnode_size"]
|
2014-02-11 18:15:50 +04:00
|
|
|
target_max_size = Kstat["kstat.zfs.misc.arcstats.c_max"]
|
|
|
|
target_min_size = Kstat["kstat.zfs.misc.arcstats.c_min"]
|
|
|
|
target_size = Kstat["kstat.zfs.misc.arcstats.c"]
|
|
|
|
|
|
|
|
target_size_ratio = (target_max_size / target_min_size)
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Sizing
|
2014-02-11 18:15:50 +04:00
|
|
|
output['arc_sizing'] = {}
|
|
|
|
output['arc_sizing']['arc_size'] = {
|
|
|
|
'per': fPerc(arc_size, target_max_size),
|
|
|
|
'num': fBytes(arc_size),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['target_max_size'] = {
|
|
|
|
'ratio': target_size_ratio,
|
|
|
|
'num': fBytes(target_max_size),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['target_min_size'] = {
|
|
|
|
'per': fPerc(target_min_size, target_max_size),
|
|
|
|
'num': fBytes(target_min_size),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['target_size'] = {
|
|
|
|
'per': fPerc(target_size, target_max_size),
|
|
|
|
'num': fBytes(target_size),
|
|
|
|
}
|
2018-08-22 19:35:20 +03:00
|
|
|
output['arc_sizing']['meta_limit'] = {
|
|
|
|
'per': fPerc(meta_limit, target_max_size),
|
|
|
|
'num': fBytes(meta_limit),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['meta_size'] = {
|
|
|
|
'per': fPerc(meta_size, meta_limit),
|
|
|
|
'num': fBytes(meta_size),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['dnode_limit'] = {
|
|
|
|
'per': fPerc(dnode_limit, meta_limit),
|
|
|
|
'num': fBytes(dnode_limit),
|
|
|
|
}
|
|
|
|
output['arc_sizing']['dnode_size'] = {
|
|
|
|
'per': fPerc(dnode_size, dnode_limit),
|
|
|
|
'num': fBytes(dnode_size),
|
|
|
|
}
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Hash Breakdown
|
2014-02-11 18:15:50 +04:00
|
|
|
output['arc_hash_break'] = {}
|
|
|
|
output['arc_hash_break']['hash_chain_max'] = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.hash_chain_max"
|
|
|
|
]
|
|
|
|
output['arc_hash_break']['hash_chains'] = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.hash_chains"
|
|
|
|
]
|
|
|
|
output['arc_hash_break']['hash_collisions'] = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.hash_collisions"
|
|
|
|
]
|
|
|
|
output['arc_hash_break']['hash_elements'] = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.hash_elements"
|
|
|
|
]
|
|
|
|
output['arc_hash_break']['hash_elements_max'] = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.hash_elements_max"
|
|
|
|
]
|
|
|
|
|
|
|
|
output['arc_size_break'] = {}
|
2017-10-24 00:18:12 +03:00
|
|
|
output['arc_size_break']['recently_used_cache_size'] = {
|
|
|
|
'per': fPerc(mru_size, mru_size + mfu_size),
|
|
|
|
'num': fBytes(mru_size),
|
|
|
|
}
|
|
|
|
output['arc_size_break']['frequently_used_cache_size'] = {
|
|
|
|
'per': fPerc(mfu_size, mru_size + mfu_size),
|
|
|
|
'num': fBytes(mfu_size),
|
|
|
|
}
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Hash Breakdown
|
2014-02-11 18:15:50 +04:00
|
|
|
hash_chain_max = Kstat["kstat.zfs.misc.arcstats.hash_chain_max"]
|
|
|
|
hash_chains = Kstat["kstat.zfs.misc.arcstats.hash_chains"]
|
|
|
|
hash_collisions = Kstat["kstat.zfs.misc.arcstats.hash_collisions"]
|
|
|
|
hash_elements = Kstat["kstat.zfs.misc.arcstats.hash_elements"]
|
|
|
|
hash_elements_max = Kstat["kstat.zfs.misc.arcstats.hash_elements_max"]
|
|
|
|
|
|
|
|
output['arc_hash_break'] = {}
|
|
|
|
output['arc_hash_break']['elements_max'] = fHits(hash_elements_max)
|
|
|
|
output['arc_hash_break']['elements_current'] = {
|
|
|
|
'per': fPerc(hash_elements, hash_elements_max),
|
|
|
|
'num': fHits(hash_elements),
|
|
|
|
}
|
|
|
|
output['arc_hash_break']['collisions'] = fHits(hash_collisions)
|
|
|
|
output['arc_hash_break']['chain_max'] = fHits(hash_chain_max)
|
|
|
|
output['arc_hash_break']['chains'] = fHits(hash_chains)
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def _arc_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print information on the ARC"""
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Sizing
|
2014-02-11 18:15:50 +04:00
|
|
|
arc = get_arc_summary(Kstat)
|
|
|
|
|
|
|
|
sys.stdout.write("ARC Summary: (%s)\n" % arc['health'])
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tMemory Throttle Count:\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['memory_throttle_count'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Misc.
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("ARC Misc:\n")
|
|
|
|
sys.stdout.write("\tDeleted:\t\t\t\t%s\n" % arc['arc_misc']['deleted'])
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tMutex Misses:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['arc_misc']['mutex_miss'])
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tEvict Skips:\t\t\t\t%s\n" %
|
2017-11-19 01:07:04 +03:00
|
|
|
arc['arc_misc']['evict_skips'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Sizing
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("ARC Size:\t\t\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['arc_size']['per'],
|
|
|
|
arc['arc_sizing']['arc_size']['num']
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tTarget Size: (Adaptive)\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['target_size']['per'],
|
|
|
|
arc['arc_sizing']['target_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\tMin Size (Hard Limit):\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['target_min_size']['per'],
|
|
|
|
arc['arc_sizing']['target_min_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\tMax Size (High Water):\t\t%d:1\t%s\n" % (
|
|
|
|
arc['arc_sizing']['target_max_size']['ratio'],
|
|
|
|
arc['arc_sizing']['target_max_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\nARC Size Breakdown:\n")
|
|
|
|
sys.stdout.write("\tRecently Used Cache Size:\t%s\t%s\n" % (
|
|
|
|
arc['arc_size_break']['recently_used_cache_size']['per'],
|
|
|
|
arc['arc_size_break']['recently_used_cache_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tFrequently Used Cache Size:\t%s\t%s\n" % (
|
|
|
|
arc['arc_size_break']['frequently_used_cache_size']['per'],
|
|
|
|
arc['arc_size_break']['frequently_used_cache_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
2018-08-22 19:35:20 +03:00
|
|
|
sys.stdout.write("\tMetadata Size (Hard Limit):\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['meta_limit']['per'],
|
|
|
|
arc['arc_sizing']['meta_limit']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tMetadata Size:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['meta_size']['per'],
|
|
|
|
arc['arc_sizing']['meta_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tDnode Size (Hard Limit):\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['dnode_limit']['per'],
|
|
|
|
arc['arc_sizing']['dnode_limit']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tDnode Size:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_sizing']['dnode_size']['per'],
|
|
|
|
arc['arc_sizing']['dnode_size']['num'],
|
|
|
|
)
|
|
|
|
)
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
# ARC Hash Breakdown
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("ARC Hash Breakdown:\n")
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tElements Max:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['arc_hash_break']['elements_max'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tElements Current:\t\t%s\t%s\n" % (
|
|
|
|
arc['arc_hash_break']['elements_current']['per'],
|
|
|
|
arc['arc_hash_break']['elements_current']['num'],
|
|
|
|
)
|
|
|
|
)
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tCollisions:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['arc_hash_break']['collisions'])
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tChain Max:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['arc_hash_break']['chain_max'])
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tChains:\t\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['arc_hash_break']['chains'])
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
def get_arc_efficiency(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect information on the efficiency of the ARC"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
output = {}
|
|
|
|
|
|
|
|
arc_hits = Kstat["kstat.zfs.misc.arcstats.hits"]
|
|
|
|
arc_misses = Kstat["kstat.zfs.misc.arcstats.misses"]
|
|
|
|
demand_data_hits = Kstat["kstat.zfs.misc.arcstats.demand_data_hits"]
|
|
|
|
demand_data_misses = Kstat["kstat.zfs.misc.arcstats.demand_data_misses"]
|
|
|
|
demand_metadata_hits = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.demand_metadata_hits"
|
|
|
|
]
|
|
|
|
demand_metadata_misses = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.demand_metadata_misses"
|
|
|
|
]
|
|
|
|
mfu_ghost_hits = Kstat["kstat.zfs.misc.arcstats.mfu_ghost_hits"]
|
|
|
|
mfu_hits = Kstat["kstat.zfs.misc.arcstats.mfu_hits"]
|
|
|
|
mru_ghost_hits = Kstat["kstat.zfs.misc.arcstats.mru_ghost_hits"]
|
|
|
|
mru_hits = Kstat["kstat.zfs.misc.arcstats.mru_hits"]
|
|
|
|
prefetch_data_hits = Kstat["kstat.zfs.misc.arcstats.prefetch_data_hits"]
|
|
|
|
prefetch_data_misses = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.prefetch_data_misses"
|
|
|
|
]
|
|
|
|
prefetch_metadata_hits = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.prefetch_metadata_hits"
|
|
|
|
]
|
|
|
|
prefetch_metadata_misses = Kstat[
|
|
|
|
"kstat.zfs.misc.arcstats.prefetch_metadata_misses"
|
|
|
|
]
|
|
|
|
|
|
|
|
anon_hits = arc_hits - (
|
|
|
|
mfu_hits + mru_hits + mfu_ghost_hits + mru_ghost_hits
|
|
|
|
)
|
|
|
|
arc_accesses_total = (arc_hits + arc_misses)
|
|
|
|
demand_data_total = (demand_data_hits + demand_data_misses)
|
|
|
|
prefetch_data_total = (prefetch_data_hits + prefetch_data_misses)
|
|
|
|
real_hits = (mfu_hits + mru_hits)
|
|
|
|
|
|
|
|
output["total_accesses"] = fHits(arc_accesses_total)
|
|
|
|
output["cache_hit_ratio"] = {
|
|
|
|
'per': fPerc(arc_hits, arc_accesses_total),
|
|
|
|
'num': fHits(arc_hits),
|
|
|
|
}
|
|
|
|
output["cache_miss_ratio"] = {
|
|
|
|
'per': fPerc(arc_misses, arc_accesses_total),
|
|
|
|
'num': fHits(arc_misses),
|
|
|
|
}
|
|
|
|
output["actual_hit_ratio"] = {
|
|
|
|
'per': fPerc(real_hits, arc_accesses_total),
|
|
|
|
'num': fHits(real_hits),
|
|
|
|
}
|
|
|
|
output["data_demand_efficiency"] = {
|
|
|
|
'per': fPerc(demand_data_hits, demand_data_total),
|
|
|
|
'num': fHits(demand_data_total),
|
|
|
|
}
|
|
|
|
|
|
|
|
if prefetch_data_total > 0:
|
|
|
|
output["data_prefetch_efficiency"] = {
|
|
|
|
'per': fPerc(prefetch_data_hits, prefetch_data_total),
|
|
|
|
'num': fHits(prefetch_data_total),
|
|
|
|
}
|
|
|
|
|
|
|
|
if anon_hits > 0:
|
|
|
|
output["cache_hits_by_cache_list"] = {}
|
|
|
|
output["cache_hits_by_cache_list"]["anonymously_used"] = {
|
|
|
|
'per': fPerc(anon_hits, arc_hits),
|
|
|
|
'num': fHits(anon_hits),
|
|
|
|
}
|
|
|
|
|
|
|
|
output["most_recently_used"] = {
|
|
|
|
'per': fPerc(mru_hits, arc_hits),
|
|
|
|
'num': fHits(mru_hits),
|
|
|
|
}
|
|
|
|
output["most_frequently_used"] = {
|
|
|
|
'per': fPerc(mfu_hits, arc_hits),
|
|
|
|
'num': fHits(mfu_hits),
|
|
|
|
}
|
|
|
|
output["most_recently_used_ghost"] = {
|
|
|
|
'per': fPerc(mru_ghost_hits, arc_hits),
|
|
|
|
'num': fHits(mru_ghost_hits),
|
|
|
|
}
|
|
|
|
output["most_frequently_used_ghost"] = {
|
|
|
|
'per': fPerc(mfu_ghost_hits, arc_hits),
|
|
|
|
'num': fHits(mfu_ghost_hits),
|
|
|
|
}
|
|
|
|
|
|
|
|
output["cache_hits_by_data_type"] = {}
|
|
|
|
output["cache_hits_by_data_type"]["demand_data"] = {
|
|
|
|
'per': fPerc(demand_data_hits, arc_hits),
|
|
|
|
'num': fHits(demand_data_hits),
|
|
|
|
}
|
|
|
|
output["cache_hits_by_data_type"]["prefetch_data"] = {
|
|
|
|
'per': fPerc(prefetch_data_hits, arc_hits),
|
|
|
|
'num': fHits(prefetch_data_hits),
|
|
|
|
}
|
|
|
|
output["cache_hits_by_data_type"]["demand_metadata"] = {
|
|
|
|
'per': fPerc(demand_metadata_hits, arc_hits),
|
|
|
|
'num': fHits(demand_metadata_hits),
|
|
|
|
}
|
|
|
|
output["cache_hits_by_data_type"]["prefetch_metadata"] = {
|
|
|
|
'per': fPerc(prefetch_metadata_hits, arc_hits),
|
|
|
|
'num': fHits(prefetch_metadata_hits),
|
|
|
|
}
|
|
|
|
|
|
|
|
output["cache_misses_by_data_type"] = {}
|
|
|
|
output["cache_misses_by_data_type"]["demand_data"] = {
|
|
|
|
'per': fPerc(demand_data_misses, arc_misses),
|
|
|
|
'num': fHits(demand_data_misses),
|
|
|
|
}
|
|
|
|
output["cache_misses_by_data_type"]["prefetch_data"] = {
|
|
|
|
'per': fPerc(prefetch_data_misses, arc_misses),
|
|
|
|
'num': fHits(prefetch_data_misses),
|
|
|
|
}
|
|
|
|
output["cache_misses_by_data_type"]["demand_metadata"] = {
|
|
|
|
'per': fPerc(demand_metadata_misses, arc_misses),
|
|
|
|
'num': fHits(demand_metadata_misses),
|
|
|
|
}
|
|
|
|
output["cache_misses_by_data_type"]["prefetch_metadata"] = {
|
|
|
|
'per': fPerc(prefetch_metadata_misses, arc_misses),
|
|
|
|
'num': fHits(prefetch_metadata_misses),
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def _arc_efficiency(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print information on the efficiency of the ARC"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
arc = get_arc_efficiency(Kstat)
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("ARC Total accesses:\t\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['total_accesses'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tCache Hit Ratio:\t\t%s\t%s\n" % (
|
|
|
|
arc['cache_hit_ratio']['per'],
|
|
|
|
arc['cache_hit_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tCache Miss Ratio:\t\t%s\t%s\n" % (
|
|
|
|
arc['cache_miss_ratio']['per'],
|
|
|
|
arc['cache_miss_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\tActual Hit Ratio:\t\t%s\t%s\n" % (
|
|
|
|
arc['actual_hit_ratio']['per'],
|
|
|
|
arc['actual_hit_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
sys.stdout.write("\tData Demand Efficiency:\t\t%s\t%s\n" % (
|
|
|
|
arc['data_demand_efficiency']['per'],
|
|
|
|
arc['data_demand_efficiency']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if 'data_prefetch_efficiency' in arc:
|
|
|
|
sys.stdout.write("\tData Prefetch Efficiency:\t%s\t%s\n" % (
|
|
|
|
arc['data_prefetch_efficiency']['per'],
|
|
|
|
arc['data_prefetch_efficiency']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
|
|
|
sys.stdout.write("\tCACHE HITS BY CACHE LIST:\n")
|
|
|
|
if 'cache_hits_by_cache_list' in arc:
|
|
|
|
sys.stdout.write("\t Anonymously Used:\t\t%s\t%s\n" % (
|
|
|
|
arc['cache_hits_by_cache_list']['anonymously_used']['per'],
|
|
|
|
arc['cache_hits_by_cache_list']['anonymously_used']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Most Recently Used:\t\t%s\t%s\n" % (
|
|
|
|
arc['most_recently_used']['per'],
|
|
|
|
arc['most_recently_used']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Most Frequently Used:\t\t%s\t%s\n" % (
|
|
|
|
arc['most_frequently_used']['per'],
|
|
|
|
arc['most_frequently_used']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Most Recently Used Ghost:\t%s\t%s\n" % (
|
|
|
|
arc['most_recently_used_ghost']['per'],
|
|
|
|
arc['most_recently_used_ghost']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Most Frequently Used Ghost:\t%s\t%s\n" % (
|
|
|
|
arc['most_frequently_used_ghost']['per'],
|
|
|
|
arc['most_frequently_used_ghost']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\n\tCACHE HITS BY DATA TYPE:\n")
|
|
|
|
sys.stdout.write("\t Demand Data:\t\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_hits_by_data_type"]['demand_data']['per'],
|
|
|
|
arc["cache_hits_by_data_type"]['demand_data']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Prefetch Data:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_hits_by_data_type"]['prefetch_data']['per'],
|
|
|
|
arc["cache_hits_by_data_type"]['prefetch_data']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Demand Metadata:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_hits_by_data_type"]['demand_metadata']['per'],
|
|
|
|
arc["cache_hits_by_data_type"]['demand_metadata']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Prefetch Metadata:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_hits_by_data_type"]['prefetch_metadata']['per'],
|
|
|
|
arc["cache_hits_by_data_type"]['prefetch_metadata']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\n\tCACHE MISSES BY DATA TYPE:\n")
|
|
|
|
sys.stdout.write("\t Demand Data:\t\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_misses_by_data_type"]['demand_data']['per'],
|
|
|
|
arc["cache_misses_by_data_type"]['demand_data']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Prefetch Data:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_misses_by_data_type"]['prefetch_data']['per'],
|
|
|
|
arc["cache_misses_by_data_type"]['prefetch_data']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Demand Metadata:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_misses_by_data_type"]['demand_metadata']['per'],
|
|
|
|
arc["cache_misses_by_data_type"]['demand_metadata']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Prefetch Metadata:\t\t%s\t%s\n" % (
|
|
|
|
arc["cache_misses_by_data_type"]['prefetch_metadata']['per'],
|
|
|
|
arc["cache_misses_by_data_type"]['prefetch_metadata']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def get_l2arc_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collection information on the L2ARC"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
output = {}
|
|
|
|
|
|
|
|
l2_abort_lowmem = Kstat["kstat.zfs.misc.arcstats.l2_abort_lowmem"]
|
|
|
|
l2_cksum_bad = Kstat["kstat.zfs.misc.arcstats.l2_cksum_bad"]
|
|
|
|
l2_evict_lock_retry = Kstat["kstat.zfs.misc.arcstats.l2_evict_lock_retry"]
|
|
|
|
l2_evict_reading = Kstat["kstat.zfs.misc.arcstats.l2_evict_reading"]
|
|
|
|
l2_feeds = Kstat["kstat.zfs.misc.arcstats.l2_feeds"]
|
|
|
|
l2_free_on_write = Kstat["kstat.zfs.misc.arcstats.l2_free_on_write"]
|
|
|
|
l2_hdr_size = Kstat["kstat.zfs.misc.arcstats.l2_hdr_size"]
|
|
|
|
l2_hits = Kstat["kstat.zfs.misc.arcstats.l2_hits"]
|
|
|
|
l2_io_error = Kstat["kstat.zfs.misc.arcstats.l2_io_error"]
|
|
|
|
l2_misses = Kstat["kstat.zfs.misc.arcstats.l2_misses"]
|
|
|
|
l2_rw_clash = Kstat["kstat.zfs.misc.arcstats.l2_rw_clash"]
|
|
|
|
l2_size = Kstat["kstat.zfs.misc.arcstats.l2_size"]
|
2014-02-11 19:14:55 +04:00
|
|
|
l2_asize = Kstat["kstat.zfs.misc.arcstats.l2_asize"]
|
2014-02-11 18:15:50 +04:00
|
|
|
l2_writes_done = Kstat["kstat.zfs.misc.arcstats.l2_writes_done"]
|
|
|
|
l2_writes_error = Kstat["kstat.zfs.misc.arcstats.l2_writes_error"]
|
|
|
|
l2_writes_sent = Kstat["kstat.zfs.misc.arcstats.l2_writes_sent"]
|
|
|
|
|
|
|
|
l2_access_total = (l2_hits + l2_misses)
|
|
|
|
output['l2_health_count'] = (l2_writes_error + l2_cksum_bad + l2_io_error)
|
|
|
|
|
|
|
|
output['l2_access_total'] = l2_access_total
|
|
|
|
output['l2_size'] = l2_size
|
2014-02-11 19:14:55 +04:00
|
|
|
output['l2_asize'] = l2_asize
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
if l2_size > 0 and l2_access_total > 0:
|
|
|
|
|
|
|
|
if output['l2_health_count'] > 0:
|
|
|
|
output["health"] = "DEGRADED"
|
|
|
|
else:
|
|
|
|
output["health"] = "HEALTHY"
|
|
|
|
|
|
|
|
output["low_memory_aborts"] = fHits(l2_abort_lowmem)
|
|
|
|
output["free_on_write"] = fHits(l2_free_on_write)
|
|
|
|
output["rw_clashes"] = fHits(l2_rw_clash)
|
|
|
|
output["bad_checksums"] = fHits(l2_cksum_bad)
|
|
|
|
output["io_errors"] = fHits(l2_io_error)
|
|
|
|
|
|
|
|
output["l2_arc_size"] = {}
|
|
|
|
output["l2_arc_size"]["adative"] = fBytes(l2_size)
|
2014-02-11 19:14:55 +04:00
|
|
|
output["l2_arc_size"]["actual"] = {
|
|
|
|
'per': fPerc(l2_asize, l2_size),
|
|
|
|
'num': fBytes(l2_asize)
|
|
|
|
}
|
2014-02-11 18:15:50 +04:00
|
|
|
output["l2_arc_size"]["head_size"] = {
|
|
|
|
'per': fPerc(l2_hdr_size, l2_size),
|
|
|
|
'num': fBytes(l2_hdr_size),
|
|
|
|
}
|
|
|
|
|
|
|
|
output["l2_arc_evicts"] = {}
|
|
|
|
output["l2_arc_evicts"]['lock_retries'] = fHits(l2_evict_lock_retry)
|
|
|
|
output["l2_arc_evicts"]['reading'] = fHits(l2_evict_reading)
|
|
|
|
|
|
|
|
output['l2_arc_breakdown'] = {}
|
|
|
|
output['l2_arc_breakdown']['value'] = fHits(l2_access_total)
|
|
|
|
output['l2_arc_breakdown']['hit_ratio'] = {
|
|
|
|
'per': fPerc(l2_hits, l2_access_total),
|
|
|
|
'num': fHits(l2_hits),
|
|
|
|
}
|
|
|
|
output['l2_arc_breakdown']['miss_ratio'] = {
|
|
|
|
'per': fPerc(l2_misses, l2_access_total),
|
|
|
|
'num': fHits(l2_misses),
|
|
|
|
}
|
|
|
|
output['l2_arc_breakdown']['feeds'] = fHits(l2_feeds)
|
|
|
|
|
|
|
|
output['l2_arc_buffer'] = {}
|
|
|
|
|
|
|
|
output['l2_arc_writes'] = {}
|
|
|
|
output['l2_writes_done'] = l2_writes_done
|
|
|
|
output['l2_writes_sent'] = l2_writes_sent
|
|
|
|
if l2_writes_done != l2_writes_sent:
|
|
|
|
output['l2_arc_writes']['writes_sent'] = {
|
|
|
|
'value': "FAULTED",
|
|
|
|
'num': fHits(l2_writes_sent),
|
|
|
|
}
|
|
|
|
output['l2_arc_writes']['done_ratio'] = {
|
|
|
|
'per': fPerc(l2_writes_done, l2_writes_sent),
|
|
|
|
'num': fHits(l2_writes_done),
|
|
|
|
}
|
|
|
|
output['l2_arc_writes']['error_ratio'] = {
|
|
|
|
'per': fPerc(l2_writes_error, l2_writes_sent),
|
|
|
|
'num': fHits(l2_writes_error),
|
|
|
|
}
|
|
|
|
else:
|
|
|
|
output['l2_arc_writes']['writes_sent'] = {
|
|
|
|
'per': fPerc(100),
|
|
|
|
'num': fHits(l2_writes_sent),
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def _l2arc_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print information on the L2ARC"""
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
arc = get_l2arc_summary(Kstat)
|
|
|
|
|
|
|
|
if arc['l2_size'] > 0 and arc['l2_access_total'] > 0:
|
|
|
|
sys.stdout.write("L2 ARC Summary: ")
|
|
|
|
if arc['l2_health_count'] > 0:
|
|
|
|
sys.stdout.write("(DEGRADED)\n")
|
|
|
|
else:
|
|
|
|
sys.stdout.write("(HEALTHY)\n")
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tLow Memory Aborts:\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['low_memory_aborts'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tFree on Write:\t\t\t\t%s\n" % arc['free_on_write'])
|
|
|
|
sys.stdout.write("\tR/W Clashes:\t\t\t\t%s\n" % arc['rw_clashes'])
|
|
|
|
sys.stdout.write("\tBad Checksums:\t\t\t\t%s\n" % arc['bad_checksums'])
|
|
|
|
sys.stdout.write("\tIO Errors:\t\t\t\t%s\n" % arc['io_errors'])
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("L2 ARC Size: (Adaptive)\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc["l2_arc_size"]["adative"])
|
2014-02-11 19:14:55 +04:00
|
|
|
sys.stdout.write("\tCompressed:\t\t\t%s\t%s\n" % (
|
|
|
|
arc["l2_arc_size"]["actual"]["per"],
|
|
|
|
arc["l2_arc_size"]["actual"]["num"],
|
|
|
|
)
|
|
|
|
)
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tHeader Size:\t\t\t%s\t%s\n" % (
|
|
|
|
arc["l2_arc_size"]["head_size"]["per"],
|
|
|
|
arc["l2_arc_size"]["head_size"]["num"],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2017-01-03 21:29:23 +03:00
|
|
|
if arc["l2_arc_evicts"]['lock_retries'] != '0' or \
|
|
|
|
arc["l2_arc_evicts"]["reading"] != '0':
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("L2 ARC Evicts:\n")
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tLock Retries:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc["l2_arc_evicts"]['lock_retries'])
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tUpon Reading:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc["l2_arc_evicts"]["reading"])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("L2 ARC Breakdown:\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['l2_arc_breakdown']['value'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tHit Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['l2_arc_breakdown']['hit_ratio']['per'],
|
|
|
|
arc['l2_arc_breakdown']['hit_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\tMiss Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['l2_arc_breakdown']['miss_ratio']['per'],
|
|
|
|
arc['l2_arc_breakdown']['miss_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
sys.stdout.write("\tFeeds:\t\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['l2_arc_breakdown']['feeds'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
|
|
|
sys.stdout.write("L2 ARC Writes:\n")
|
|
|
|
if arc['l2_writes_done'] != arc['l2_writes_sent']:
|
|
|
|
sys.stdout.write("\tWrites Sent: (%s)\t\t\t\t%s\n" % (
|
|
|
|
arc['l2_arc_writes']['writes_sent']['value'],
|
|
|
|
arc['l2_arc_writes']['writes_sent']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Done Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['l2_arc_writes']['done_ratio']['per'],
|
|
|
|
arc['l2_arc_writes']['done_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\t Error Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['l2_arc_writes']['error_ratio']['per'],
|
|
|
|
arc['l2_arc_writes']['error_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
sys.stdout.write("\tWrites Sent:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['l2_arc_writes']['writes_sent']['per'],
|
|
|
|
arc['l2_arc_writes']['writes_sent']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def get_dmu_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect information on the DMU"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
output = {}
|
|
|
|
|
|
|
|
zfetch_hits = Kstat["kstat.zfs.misc.zfetchstats.hits"]
|
|
|
|
zfetch_misses = Kstat["kstat.zfs.misc.zfetchstats.misses"]
|
|
|
|
|
|
|
|
zfetch_access_total = (zfetch_hits + zfetch_misses)
|
|
|
|
output['zfetch_access_total'] = zfetch_access_total
|
|
|
|
|
|
|
|
if zfetch_access_total > 0:
|
|
|
|
output['dmu'] = {}
|
|
|
|
output['dmu']['efficiency'] = {}
|
|
|
|
output['dmu']['efficiency']['value'] = fHits(zfetch_access_total)
|
|
|
|
output['dmu']['efficiency']['hit_ratio'] = {
|
|
|
|
'per': fPerc(zfetch_hits, zfetch_access_total),
|
|
|
|
'num': fHits(zfetch_hits),
|
|
|
|
}
|
|
|
|
output['dmu']['efficiency']['miss_ratio'] = {
|
|
|
|
'per': fPerc(zfetch_misses, zfetch_access_total),
|
|
|
|
'num': fHits(zfetch_misses),
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def _dmu_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print information on the DMU"""
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
arc = get_dmu_summary(Kstat)
|
|
|
|
|
|
|
|
if arc['zfetch_access_total'] > 0:
|
2016-07-16 00:30:52 +03:00
|
|
|
sys.stdout.write("DMU Prefetch Efficiency:\t\t\t\t\t%s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
arc['dmu']['efficiency']['value'])
|
2014-02-11 18:15:50 +04:00
|
|
|
sys.stdout.write("\tHit Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['dmu']['efficiency']['hit_ratio']['per'],
|
|
|
|
arc['dmu']['efficiency']['hit_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
sys.stdout.write("\tMiss Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['dmu']['efficiency']['miss_ratio']['per'],
|
|
|
|
arc['dmu']['efficiency']['miss_ratio']['num'],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
|
|
|
|
|
|
|
|
def get_vdev_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Collect information on the VDEVs"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
output = {}
|
|
|
|
|
2015-01-13 21:28:55 +03:00
|
|
|
vdev_cache_delegations = \
|
2016-10-06 20:04:54 +03:00
|
|
|
Kstat["kstat.zfs.misc.vdev_cache_stats.delegations"]
|
2014-02-11 18:15:50 +04:00
|
|
|
vdev_cache_misses = Kstat["kstat.zfs.misc.vdev_cache_stats.misses"]
|
|
|
|
vdev_cache_hits = Kstat["kstat.zfs.misc.vdev_cache_stats.hits"]
|
2015-01-13 21:28:55 +03:00
|
|
|
vdev_cache_total = (vdev_cache_misses + vdev_cache_hits +
|
2016-10-06 20:04:54 +03:00
|
|
|
vdev_cache_delegations)
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
output['vdev_cache_total'] = vdev_cache_total
|
|
|
|
|
|
|
|
if vdev_cache_total > 0:
|
|
|
|
output['summary'] = fHits(vdev_cache_total)
|
|
|
|
output['hit_ratio'] = {
|
|
|
|
'per': fPerc(vdev_cache_hits, vdev_cache_total),
|
|
|
|
'num': fHits(vdev_cache_hits),
|
|
|
|
}
|
|
|
|
output['miss_ratio'] = {
|
|
|
|
'per': fPerc(vdev_cache_misses, vdev_cache_total),
|
|
|
|
'num': fHits(vdev_cache_misses),
|
|
|
|
}
|
|
|
|
output['delegations'] = {
|
|
|
|
'per': fPerc(vdev_cache_delegations, vdev_cache_total),
|
|
|
|
'num': fHits(vdev_cache_delegations),
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
def _vdev_summary(Kstat):
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print information on the VDEVs"""
|
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
arc = get_vdev_summary(Kstat)
|
|
|
|
|
|
|
|
if arc['vdev_cache_total'] > 0:
|
|
|
|
sys.stdout.write("VDEV Cache Summary:\t\t\t\t%s\n" % arc['summary'])
|
|
|
|
sys.stdout.write("\tHit Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['hit_ratio']['per'],
|
|
|
|
arc['hit_ratio']['num'],
|
|
|
|
))
|
|
|
|
sys.stdout.write("\tMiss Ratio:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['miss_ratio']['per'],
|
|
|
|
arc['miss_ratio']['num'],
|
|
|
|
))
|
|
|
|
sys.stdout.write("\tDelegations:\t\t\t%s\t%s\n" % (
|
|
|
|
arc['delegations']['per'],
|
|
|
|
arc['delegations']['num'],
|
|
|
|
))
|
|
|
|
|
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
def _tunable_summary(Kstat):
|
2017-11-12 07:27:43 +03:00
|
|
|
"""Print information on tunables, including descriptions if requested"""
|
2017-11-06 00:11:37 +03:00
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
global show_tunable_descriptions
|
|
|
|
global alternate_tunable_layout
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
def load_tunables():
|
|
|
|
basepath = '/sys/module/zfs/parameters'
|
|
|
|
tunables = {}
|
|
|
|
for name in os.listdir(basepath):
|
|
|
|
if not name:
|
|
|
|
continue
|
|
|
|
path = '%s/%s' % (basepath, name)
|
|
|
|
with open(path) as f:
|
|
|
|
value = f.read()
|
|
|
|
tunables[name] = value.strip()
|
|
|
|
return tunables
|
|
|
|
|
|
|
|
tunables = load_tunables()
|
2015-01-13 00:31:24 +03:00
|
|
|
descriptions = {}
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
if show_tunable_descriptions:
|
2017-11-12 07:27:43 +03:00
|
|
|
|
|
|
|
command = ["/sbin/modinfo", "zfs", "-0"]
|
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
try:
|
|
|
|
p = Popen(command, stdin=PIPE, stdout=PIPE,
|
2016-10-06 20:04:54 +03:00
|
|
|
stderr=PIPE, shell=False, close_fds=True)
|
2015-01-13 00:31:24 +03:00
|
|
|
p.wait()
|
|
|
|
|
2017-11-12 07:27:43 +03:00
|
|
|
# By default, Python 2 returns a string as the first element of the
|
|
|
|
# tuple from p.communicate(), while Python 3 returns bytes which
|
|
|
|
# must be decoded first. The better way to do this would be with
|
|
|
|
# subprocess.run() or at least .check_output(), but this fails on
|
|
|
|
# CentOS 6 because of its old version of Python 2
|
|
|
|
desc = bytes.decode(p.communicate()[0])
|
|
|
|
description_list = desc.strip().split('\0')
|
2015-01-13 00:31:24 +03:00
|
|
|
|
|
|
|
if p.returncode == 0:
|
|
|
|
for tunable in description_list:
|
|
|
|
if tunable[0:5] == 'parm:':
|
|
|
|
tunable = tunable[5:].strip()
|
|
|
|
name, description = tunable.split(':', 1)
|
|
|
|
if not description:
|
|
|
|
description = "Description unavailable"
|
|
|
|
descriptions[name] = description
|
|
|
|
else:
|
|
|
|
sys.stderr.write("%s: '%s' exited with code %i\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
(sys.argv[0], command[0], p.returncode))
|
2015-01-13 00:31:24 +03:00
|
|
|
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
|
|
|
except OSError as e:
|
|
|
|
sys.stderr.write("%s: Cannot run '%s': %s\n" %
|
2016-10-06 20:04:54 +03:00
|
|
|
(sys.argv[0], command[0], e.strerror))
|
2015-01-13 00:31:24 +03:00
|
|
|
sys.stderr.write("Tunable descriptions will be disabled.\n")
|
|
|
|
|
2017-11-12 07:27:43 +03:00
|
|
|
sys.stdout.write("ZFS Tunables:\n")
|
2017-11-08 01:50:15 +03:00
|
|
|
|
|
|
|
if alternate_tunable_layout:
|
2017-11-15 21:28:11 +03:00
|
|
|
fmt = "\t%s=%s\n"
|
2017-11-08 01:50:15 +03:00
|
|
|
else:
|
2017-11-15 21:28:11 +03:00
|
|
|
fmt = "\t%-50s%s\n"
|
2017-11-08 01:50:15 +03:00
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
for name in sorted(tunables.keys()):
|
2016-01-01 04:20:43 +03:00
|
|
|
if show_tunable_descriptions and name in descriptions:
|
2015-01-13 00:31:24 +03:00
|
|
|
sys.stdout.write("\t# %s\n" % descriptions[name])
|
|
|
|
|
2019-09-10 22:17:54 +03:00
|
|
|
sys.stdout.write(fmt % (name, tunables[name]))
|
2015-01-13 00:31:24 +03:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
unSub = [
|
|
|
|
_arc_summary,
|
|
|
|
_arc_efficiency,
|
|
|
|
_l2arc_summary,
|
|
|
|
_dmu_summary,
|
|
|
|
_vdev_summary,
|
2015-01-13 00:31:24 +03:00
|
|
|
_tunable_summary
|
2014-02-11 18:15:50 +04:00
|
|
|
]
|
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
def zfs_header():
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print title string with date"""
|
|
|
|
|
2017-11-04 01:43:53 +03:00
|
|
|
daydate = time.strftime('%a %b %d %H:%M:%S %Y')
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2017-11-04 01:43:53 +03:00
|
|
|
sys.stdout.write('\n'+'-'*72+'\n')
|
|
|
|
sys.stdout.write('ZFS Subsystem Report\t\t\t\t%s' % daydate)
|
|
|
|
sys.stdout.write('\n')
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
|
2014-12-04 22:31:54 +03:00
|
|
|
def usage():
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Print usage information"""
|
|
|
|
|
pyzfs: python3 support (build system)
Almost all of the Python code in the respository has been updated
to be compatibile with Python 2.6, Python 3.4, or newer. The only
exceptions are arc_summery3.py which requires Python 3, and pyzfs
which requires at least Python 2.7. This allows us to maintain a
single version of the code and support most default versions of
python. This change does the following:
* Sets the default shebang for all Python scripts to python3. If
only Python 2 is available, then at install time scripts which
are compatible with Python 2 will have their shebangs replaced
with /usr/bin/python. This is done for compatibility until
Python 2 goes end of life. Since only the installed versions
are changed this means Python 3 must be installed on the system
for test-runner when testing in-tree.
* Added --with-python=<2|3|3.4,etc> configure option which sets
the PYTHON environment variable to target a specific python
version. By default the newest installed version of Python
will be used or the preferred distribution version when
creating pacakges.
* Fixed --enable-pyzfs configure checks so they are run when
--enable-pyzfs=check and --enable-pyzfs=yes.
* Enabled pyzfs for Python 3.4 and newer, which is now supported.
* Renamed pyzfs package to python<VERSION>-pyzfs and updated to
install in the appropriate site location. For example, when
building with --with-python=3.4 a python34-pyzfs will be
created which installs in /usr/lib/python3.4/site-packages/.
* Renamed the following python scripts according to the Fedora
guidance for packaging utilities in /bin
- dbufstat.py -> dbufstat
- arcstat.py -> arcstat
- arc_summary.py -> arc_summary
- arc_summary3.py -> arc_summary3
* Updated python-cffi package name. On CentOS 6, CentOS 7, and
Amazon Linux it's called python-cffi, not python2-cffi. For
Python3 it's called python3-cffi or python3x-cffi.
* Install one version of arc_summary. Depending on the version
of Python available install either arc_summary2 or arc_summary3
as arc_summary. The user output is only slightly different.
Reviewed-by: John Ramsden <johnramsden@riseup.net>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8096
2018-10-31 19:22:59 +03:00
|
|
|
sys.stdout.write("Usage: arc_summary [-h] [-a] [-d] [-p PAGE]\n\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("\t -h, --help : "
|
2016-10-06 20:04:54 +03:00
|
|
|
"Print this help message and exit\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("\t -a, --alternate : "
|
2016-10-06 20:04:54 +03:00
|
|
|
"Show an alternate sysctl layout\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("\t -d, --description : "
|
2016-10-06 20:04:54 +03:00
|
|
|
"Show the sysctl descriptions\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("\t -p PAGE, --page=PAGE : "
|
2016-10-06 20:04:54 +03:00
|
|
|
"Select a single output page to display,\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("\t "
|
2016-10-06 20:04:54 +03:00
|
|
|
"should be an integer between 1 and " +
|
|
|
|
str(len(unSub)) + "\n\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
sys.stdout.write("Examples:\n")
|
pyzfs: python3 support (build system)
Almost all of the Python code in the respository has been updated
to be compatibile with Python 2.6, Python 3.4, or newer. The only
exceptions are arc_summery3.py which requires Python 3, and pyzfs
which requires at least Python 2.7. This allows us to maintain a
single version of the code and support most default versions of
python. This change does the following:
* Sets the default shebang for all Python scripts to python3. If
only Python 2 is available, then at install time scripts which
are compatible with Python 2 will have their shebangs replaced
with /usr/bin/python. This is done for compatibility until
Python 2 goes end of life. Since only the installed versions
are changed this means Python 3 must be installed on the system
for test-runner when testing in-tree.
* Added --with-python=<2|3|3.4,etc> configure option which sets
the PYTHON environment variable to target a specific python
version. By default the newest installed version of Python
will be used or the preferred distribution version when
creating pacakges.
* Fixed --enable-pyzfs configure checks so they are run when
--enable-pyzfs=check and --enable-pyzfs=yes.
* Enabled pyzfs for Python 3.4 and newer, which is now supported.
* Renamed pyzfs package to python<VERSION>-pyzfs and updated to
install in the appropriate site location. For example, when
building with --with-python=3.4 a python34-pyzfs will be
created which installs in /usr/lib/python3.4/site-packages/.
* Renamed the following python scripts according to the Fedora
guidance for packaging utilities in /bin
- dbufstat.py -> dbufstat
- arcstat.py -> arcstat
- arc_summary.py -> arc_summary
- arc_summary3.py -> arc_summary3
* Updated python-cffi package name. On CentOS 6, CentOS 7, and
Amazon Linux it's called python-cffi, not python2-cffi. For
Python3 it's called python3-cffi or python3x-cffi.
* Install one version of arc_summary. Depending on the version
of Python available install either arc_summary2 or arc_summary3
as arc_summary. The user output is only slightly different.
Reviewed-by: John Ramsden <johnramsden@riseup.net>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8096
2018-10-31 19:22:59 +03:00
|
|
|
sys.stdout.write("\tarc_summary -a\n")
|
|
|
|
sys.stdout.write("\tarc_summary -p 4\n")
|
|
|
|
sys.stdout.write("\tarc_summary -ad\n")
|
|
|
|
sys.stdout.write("\tarc_summary --page=2\n")
|
2014-12-04 22:31:54 +03:00
|
|
|
|
2016-10-06 20:04:54 +03:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
def main():
|
2017-11-06 00:11:37 +03:00
|
|
|
"""Main function"""
|
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
global show_tunable_descriptions
|
|
|
|
global alternate_tunable_layout
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2017-12-20 00:02:40 +03:00
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(
|
|
|
|
sys.argv[1:],
|
|
|
|
"adp:h", ["alternate", "description", "page=", "help"]
|
|
|
|
)
|
|
|
|
except getopt.error as e:
|
|
|
|
sys.stderr.write("Error: %s\n" % e.msg)
|
|
|
|
usage()
|
|
|
|
sys.exit(1)
|
2014-02-11 18:15:50 +04:00
|
|
|
|
|
|
|
args = {}
|
|
|
|
for opt, arg in opts:
|
2014-12-04 22:31:54 +03:00
|
|
|
if opt in ('-a', '--alternate'):
|
2014-02-11 18:15:50 +04:00
|
|
|
args['a'] = True
|
2014-12-04 22:31:54 +03:00
|
|
|
if opt in ('-d', '--description'):
|
2014-02-11 18:15:50 +04:00
|
|
|
args['d'] = True
|
2014-12-04 22:31:54 +03:00
|
|
|
if opt in ('-p', '--page'):
|
2014-02-11 18:15:50 +04:00
|
|
|
args['p'] = arg
|
2014-12-04 22:31:54 +03:00
|
|
|
if opt in ('-h', '--help'):
|
|
|
|
usage()
|
2017-12-20 00:02:40 +03:00
|
|
|
sys.exit(0)
|
2014-02-11 18:15:50 +04:00
|
|
|
|
Refactor arc_summary to simplify -p processing
The -p option is used to specify a specific page of output to be
displayed. If omitted, all output pages would be displayed.
arc_summary, as it stood, had really kludgy processing code for
processing the -p option. It relied on a try-except block which was
treated as an if statement and in normal operation would fail any time a
user didn't specify the -p option on the command line. When the
exception was thrown, the script would then display all output pages.
This happened whether the -p option was omitted or malformed. Thus, in
the principle use case, an exception would be raised in order to run the
script as desired. The same except code would be called regardless of
the exception, however, and malformed -p arguments would also cause the
script to execute.
Additionally, this required the function which handles the case where
all output pages were to be displayed, _call_all, to be potentially
called from several locations within main.
This commit refactors the option processing code to simplify it and make
it easier to catch runtime errors in the script. This is done by
specializing the try-except block to only have an exception when the -p
argument is malformed. When the -p option is correctly selected by the
user, it calls a function in the unSub array directly, which will only
display one page of output.
Finally in the context of this refactoring the page breaks have been
removed. Pages seem to have been added into the output in the FreeNAS
version of the script. This patch removes pages from the output to more
closely resemble the freebsd version of the script.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
2014-11-05 21:08:45 +03:00
|
|
|
Kstat = get_Kstat()
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2015-01-13 00:31:24 +03:00
|
|
|
alternate_tunable_layout = 'a' in args
|
|
|
|
show_tunable_descriptions = 'd' in args
|
2014-02-11 18:15:50 +04:00
|
|
|
|
Refactor arc_summary to simplify -p processing
The -p option is used to specify a specific page of output to be
displayed. If omitted, all output pages would be displayed.
arc_summary, as it stood, had really kludgy processing code for
processing the -p option. It relied on a try-except block which was
treated as an if statement and in normal operation would fail any time a
user didn't specify the -p option on the command line. When the
exception was thrown, the script would then display all output pages.
This happened whether the -p option was omitted or malformed. Thus, in
the principle use case, an exception would be raised in order to run the
script as desired. The same except code would be called regardless of
the exception, however, and malformed -p arguments would also cause the
script to execute.
Additionally, this required the function which handles the case where
all output pages were to be displayed, _call_all, to be potentially
called from several locations within main.
This commit refactors the option processing code to simplify it and make
it easier to catch runtime errors in the script. This is done by
specializing the try-except block to only have an exception when the -p
argument is malformed. When the -p option is correctly selected by the
user, it calls a function in the unSub array directly, which will only
display one page of output.
Finally in the context of this refactoring the page breaks have been
removed. Pages seem to have been added into the output in the FreeNAS
version of the script. This patch removes pages from the output to more
closely resemble the freebsd version of the script.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
2014-11-05 21:08:45 +03:00
|
|
|
pages = []
|
|
|
|
|
|
|
|
if 'p' in args:
|
|
|
|
try:
|
|
|
|
pages.append(unSub[int(args['p']) - 1])
|
2016-10-06 20:04:54 +03:00
|
|
|
except IndexError:
|
Refactor arc_summary to simplify -p processing
The -p option is used to specify a specific page of output to be
displayed. If omitted, all output pages would be displayed.
arc_summary, as it stood, had really kludgy processing code for
processing the -p option. It relied on a try-except block which was
treated as an if statement and in normal operation would fail any time a
user didn't specify the -p option on the command line. When the
exception was thrown, the script would then display all output pages.
This happened whether the -p option was omitted or malformed. Thus, in
the principle use case, an exception would be raised in order to run the
script as desired. The same except code would be called regardless of
the exception, however, and malformed -p arguments would also cause the
script to execute.
Additionally, this required the function which handles the case where
all output pages were to be displayed, _call_all, to be potentially
called from several locations within main.
This commit refactors the option processing code to simplify it and make
it easier to catch runtime errors in the script. This is done by
specializing the try-except block to only have an exception when the -p
argument is malformed. When the -p option is correctly selected by the
user, it calls a function in the unSub array directly, which will only
display one page of output.
Finally in the context of this refactoring the page breaks have been
removed. Pages seem to have been added into the output in the FreeNAS
version of the script. This patch removes pages from the output to more
closely resemble the freebsd version of the script.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
2014-11-05 21:08:45 +03:00
|
|
|
sys.stderr.write('the argument to -p must be between 1 and ' +
|
2016-10-06 20:04:54 +03:00
|
|
|
str(len(unSub)) + '\n')
|
2017-12-20 00:02:40 +03:00
|
|
|
sys.exit(1)
|
2014-02-11 18:15:50 +04:00
|
|
|
else:
|
Refactor arc_summary to simplify -p processing
The -p option is used to specify a specific page of output to be
displayed. If omitted, all output pages would be displayed.
arc_summary, as it stood, had really kludgy processing code for
processing the -p option. It relied on a try-except block which was
treated as an if statement and in normal operation would fail any time a
user didn't specify the -p option on the command line. When the
exception was thrown, the script would then display all output pages.
This happened whether the -p option was omitted or malformed. Thus, in
the principle use case, an exception would be raised in order to run the
script as desired. The same except code would be called regardless of
the exception, however, and malformed -p arguments would also cause the
script to execute.
Additionally, this required the function which handles the case where
all output pages were to be displayed, _call_all, to be potentially
called from several locations within main.
This commit refactors the option processing code to simplify it and make
it easier to catch runtime errors in the script. This is done by
specializing the try-except block to only have an exception when the -p
argument is malformed. When the -p option is correctly selected by the
user, it calls a function in the unSub array directly, which will only
display one page of output.
Finally in the context of this refactoring the page breaks have been
removed. Pages seem to have been added into the output in the FreeNAS
version of the script. This patch removes pages from the output to more
closely resemble the freebsd version of the script.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
2014-11-05 21:08:45 +03:00
|
|
|
pages = unSub
|
2014-02-11 18:15:50 +04:00
|
|
|
|
Refactor arc_summary to simplify -p processing
The -p option is used to specify a specific page of output to be
displayed. If omitted, all output pages would be displayed.
arc_summary, as it stood, had really kludgy processing code for
processing the -p option. It relied on a try-except block which was
treated as an if statement and in normal operation would fail any time a
user didn't specify the -p option on the command line. When the
exception was thrown, the script would then display all output pages.
This happened whether the -p option was omitted or malformed. Thus, in
the principle use case, an exception would be raised in order to run the
script as desired. The same except code would be called regardless of
the exception, however, and malformed -p arguments would also cause the
script to execute.
Additionally, this required the function which handles the case where
all output pages were to be displayed, _call_all, to be potentially
called from several locations within main.
This commit refactors the option processing code to simplify it and make
it easier to catch runtime errors in the script. This is done by
specializing the try-except block to only have an exception when the -p
argument is malformed. When the -p option is correctly selected by the
user, it calls a function in the unSub array directly, which will only
display one page of output.
Finally in the context of this refactoring the page breaks have been
removed. Pages seem to have been added into the output in the FreeNAS
version of the script. This patch removes pages from the output to more
closely resemble the freebsd version of the script.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Kyle Blatter <kyleblatter@llnl.gov>
Signed-off-by: Ned Bass <bass6@llnl.gov>
2014-11-05 21:08:45 +03:00
|
|
|
zfs_header()
|
|
|
|
for page in pages:
|
|
|
|
page(Kstat)
|
2017-11-04 01:43:53 +03:00
|
|
|
sys.stdout.write("\n")
|
2014-02-11 18:15:50 +04:00
|
|
|
|
2017-03-09 21:21:59 +03:00
|
|
|
|
2014-02-11 18:15:50 +04:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|