xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/zpool_influxdb/zpool_influxdb.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms of the
7# Common Development and Distribution License (the "License").
8# You may not use this file except in compliance with the License.
9#
10# You can obtain a copy of the license at
11# https://opensource.org/licenses/CDDL-1.0
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23
24#
25# Copyright 2020 Richard Elling
26#
27
28. $STF_SUITE/include/libtest.shlib
29
30typeset tmpfile=$TEST_BASE_DIR/zpool_influxdb.out.$$
31function cleanup
32{
33	if [[ -f $tmpfile ]]; then
34		rm -f $tmpfile
35	fi
36}
37log_onexit cleanup
38
39log_assert "zpool_influxdb gathers statistics"
40
41if ! is_global_zone ; then
42	TESTPOOL=${TESTPOOL%%/*}
43fi
44
45function check_for
46{
47    log_must grep -q "^${1}," $tmpfile
48}
49
50# by default, all stats and histograms for all pools
51log_must eval "zpool_influxdb > $tmpfile"
52
53STATS="
54zpool_io_size
55zpool_latency
56zpool_stats
57zpool_vdev_queue
58zpool_vdev_stats
59"
60for stat in $STATS; do
61    check_for $stat
62done
63
64# scan stats aren't expected to be there until after a scan has started
65log_must zpool scrub $TESTPOOL
66log_must eval "zpool_influxdb > $tmpfile"
67check_for zpool_scan_stats
68
69log_pass "zpool_influxdb gathers statistics"
70