diff options
author | Ryan Moeller <[email protected]> | 2019-11-30 18:43:23 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-11-30 15:43:23 -0800 |
commit | 101f9b1771a638947697e46f3acc16addefdf9f5 (patch) | |
tree | 17c388ba3b0aadbce771d1bda529e7cf7eea2abe /cmd/arc_summary/arc_summary3 | |
parent | c54687cd2360d01c8237058f16293572b2a2eedb (diff) |
Add FreeBSD code to arc_summary and arcstat
Adding the FreeBSD code allows arc_summary and arcstat
to be used on FreeBSD.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #9641
Diffstat (limited to 'cmd/arc_summary/arc_summary3')
-rwxr-xr-x | cmd/arc_summary/arc_summary3 | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/cmd/arc_summary/arc_summary3 b/cmd/arc_summary/arc_summary3 index 5d1c5d5b4..af49fe3ab 100755 --- a/cmd/arc_summary/arc_summary3 +++ b/cmd/arc_summary/arc_summary3 @@ -80,10 +80,42 @@ parser.add_argument('-s', '--section', dest='section', help=SECTION_HELP) ARGS = parser.parse_args() -if sys.platform.startswith('linux'): - KSTAT_PATH = '/proc/spl/kstat/zfs/' - SPL_PATH = '/sys/module/spl/parameters/' - TUNABLES_PATH = '/sys/module/zfs/parameters/' +if sys.platform.startswith('freebsd'): + # Requires py36-sysctl on FreeBSD + import sysctl + + VDEV_CACHE_SIZE = 'vdev.cache_size' + + def load_kstats(section): + base = 'kstat.zfs.misc.{section}.'.format(section=section) + # base is removed from the name + fmt = lambda kstat: '{name} : {value}'.format(name=kstat.name[len(base):], + value=kstat.value) + return [fmt(kstat) for kstat in sysctl.filter(base)] + + def get_params(base): + cut = 8 # = len('vfs.zfs.') + return {ctl.name[cut:]: str(ctl.value) for ctl in sysctl.filter(base)} + + def get_tunable_params(): + return get_params('vfs.zfs') + + def get_vdev_params(): + return get_params('vfs.zfs.vdev') + + def get_version_impl(request): + # FreeBSD reports versions for zpl and spa instead of zfs and spl. + name = {'zfs': 'zpl', + 'spl': 'spa'}[request] + mib = 'vfs.zfs.version.{}'.format(name) + version = sysctl.filter(mib)[0].value + return '{} version {}'.format(name, version) + +elif sys.platform.startswith('linux'): + KSTAT_PATH = '/proc/spl/kstat/zfs' + SPL_PATH = '/sys/module/spl/parameters' + TUNABLES_PATH = '/sys/module/zfs/parameters' + VDEV_CACHE_SIZE = 'zfs_vdev_cache_size' def load_kstats(section): @@ -720,6 +752,10 @@ def section_spl(*_): and/or descriptions. This does not use kstats. """ + if sys.platform.startswith('freebsd'): + # No SPL support in FreeBSD + return + spls = get_spl_params() keylist = sorted(spls.keys()) print('Solaris Porting Layer (SPL):') |