xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/callbacks/zfs_mmp.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3
4#
5# This file and its contents are supplied under the terms of the
6# Common Development and Distribution License ("CDDL"), version 1.0.
7# You may only use this file in accordance with the terms of version
8# 1.0 of the CDDL.
9#
10# A full copy of the text of the CDDL should have accompanied this
11# source.  A copy of the CDDL is also available via the Internet at
12# http://www.illumos.org/license/CDDL.
13#
14
15#
16# Copyright (c) 2017 by Lawrence Livermore National Security.
17# All rights reserved.
18#
19
20# $1: number of lines to output (default: 40)
21typeset lines=${1:-40}
22typeset history=$(</sys/module/zfs/parameters/zfs_multihost_history)
23
24if [ $history -eq 0 ]; then
25	exit
26fi
27
28for f in /proc/spl/kstat/zfs/*/multihost; do
29	echo "================================================================="
30	echo " Last $lines lines of $f"
31	echo "================================================================="
32
33	sudo tail -n $lines $f
34	sudo bash -c "echo > $f"
35done
36
37echo "================================================================="
38echo " End of zfs multihost log"
39echo "================================================================="
40