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