1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#!/bin/sh
# PCP QA Test No. 1397
# Test pmdasmart (S.M.A.R.T Data collection) metrics
#
# Copyright (c) 2018 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
_check_valgrind
[ $PCP_PLATFORM = linux ] || _notrun "SMART PMDA is Linux-specific (smart)"
[ -d $PCP_PMDAS_DIR/smart ] || _notrun "smart PMDA directory is not installed"
which smartctl >/dev/null 2>&1 || _notrun "smart PMDA Install needs smartctl(1)"
_cleanup()
{
cd $here
_restore_pmda_install smart
$sudo rm -fr $tmp.root
$sudo rm -f $tmp.*
}
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter()
{
$here/src/sortinst | \
sed \
-e "s,$PCP_PMDAS_DIR,PCP_PMDAS_DIR,g" \
#end
}
# real QA test starts here
echo
echo "=== Installing S.M.A.R.T PMDA ===" | tee -a $seq_full
_prepare_pmda_install smart || _exit 1
cd $PCP_PMDAS_DIR/smart
$sudo ./Install </dev/null >$tmp.out 2>&1
cat $tmp.out >> $seq_full
root=$tmp.root
SMART_SETUP_LSBLK="$here/smart/lsblk.sh"; export SMART_SETUP_LSBLK
SMART_SETUP="$here/smart/smartctl.sh"; export SMART_SETUP
NVME_CLI_SETUP="$here/smart/nvme_cli.sh"; export NVME_CLI_SETUP
pmda=$PCP_PMDAS_DIR/smart/pmda_smart.so,smart_init
metrics=`pminfo -L -K clear -K add,150,$pmda smart | LC_COLLATE=POSIX sort`
memcheck="smart.health smart.info.capacity_bytes smart.attributes.power_off_retract_count.worst smart.nvme_attributes.data_units_read smart.nvme_info.serial_number smart.nvme_info.active_power_state smart.nvme_power_states.power_state_1.state"
for tgz in $here/smart/smart-*.tgz
do
[ $tgz = "smart/smart-*" ] && continue
$sudo rm -fr $root
mkdir $root || _fail "root in use when processing $tgz"
cd $root
$sudo tar xzf $tgz
base=`basename $tgz`
count=`echo $base | sed -e 's,.*-root-,,g' -e 's,.tgz$,,g'`
cd $count/smart
SMART_SETUP_UUID="$root/$count/smart/wwid"; export SMART_SETUP_UUID
echo "== Checking metric descriptors and values - $base"
pminfo -L -K clear -K add,150,$pmda -dfmtT $metrics 2>&1 \
| _filter
echo "== Checking with valgrind - $base"
_run_valgrind pminfo -L -K clear -K add,150,$pmda -f $memcheck 2>&1 \
| _filter
echo && echo "== done" && echo
cd $here
done
# cleanup ..
#
cd $PCP_PMDAS_DIR/smart
$sudo ./Remove </dev/null >/dev/null 2>&1
# success, all done
status=0
exit
|