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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#!/bin/sh
# PCP QA Test No. 1187
# Exercise pcp-dstat archive mode and CSV functionality.
# - live metrics part has been split off to qa/1636
#
# Copyright (c) 2018-2021 Red Hat. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
DSTAT="$PCP_BINADM_DIR/pcp-dstat"
test -f "$DSTAT" || _notrun "$DSTAT is not installed, skipped"
_cleanup()
{
cd $here
$sudo rm -rf $tmp $tmp.*
}
status=1 # failure is the default!
username=`id -u -n`
trap "_cleanup; exit \$status" 0 1 2 3 15
# read from the pcp-dstat archive with various dstat options
#
dstat_archive()
{
archive="$1"
message="$2"
shift
shift
options="$@"
echo "$message"
pcp_options="pcp -z --origin=+0.1 --archive $archive"
$pcp_options dstat --time $options 1 3 >$tmp.out 2>$tmp.err
echo "=== std out"
cat $tmp.out
echo "=== std err"
cat $tmp.err
echo "=== done" && echo
}
dstat()
{
dstat_archive "$here/archives/pcp-dstat" "$@"
}
dstat_amdgpu()
{
dstat_archive "$here/archives/amdgpu" "$@"
}
dstat_nvidiagpu()
{
dstat_archive "$here/archives/nvidiagpu" "$@"
}
filter_info()
{
sed \
-e "/^$(printf '\t')/d" \
-e "/^.GCC /d" \
-e "s/^Python .*/Python VERSION/g" \
-e "s,$PCP_SYSCONF_DIR,/etc/pcp,g" \
-e "s,pcp-dstat $PCP_VERSION,pcp-dstat VERSION,g" \
-e "s/\"User:\",\"$username\"/\"User:\",\"USER\"/g" \
-e "s/\"Date:\",\".*\"/\"Date:\",\"DATE\"/g" \
-e "s,-o $tmp.csv,-o TMP.csv,g" \
#end
}
# real QA test starts here
TERM=ansi; export TERM
dstat "All defaults to EOL"
dstat "Per CPU" --cpu -C 1,2,total --cpu-use
dstat "CPU" --cpu-adv
dstat_nvidiagpu "NVIDIA GPU" --nvidia-gpu
dstat_amdgpu "AMD GPU" --amd-gpu -G 0
dstat "Per Disk" --disk -D vda,total --disk-wait
dstat "All Disks" --disk --full
dstat "Zero Disks" --all -D --full
dstat "Disk" --io
dstat "Kernel" --ipc --sys --utmp
dstat "Memory" --mem-adv --swap
dstat "Per Interface" --net -N enp0s25,wlp3s0,tun0
dstat "Per Interface in bits" --net -N enp0s25 --bits
dstat "Per Interface packets" --net-packets -N enp0s25,wlp3s0,tun0
dstat "All Interfaces" --net --full
dstat "Network" --socket --tcp
dstat "Processes" --proc
dstat "Filesystem" --aio --fs --lock
dstat "Filesystem alias" --aio --filesystem --lock
dstat "Duplicate arguments" -ddd
dstat "Overlapping arguments" -dam
dstat "Version" --version | filter_info
dstat "Plugins" --list | filter_info
# No stdout/stderr redirecting
echo "Piping"
pcp -z --archive $here/archives/pcp-dstat dstat --time 1 3 | head -n 3
echo "=== done" && echo
# No existing archive
echo "Missing archive"
pcp -z --archive /nosuchfile dstat --version
echo "=== done" && echo
dstat "CSV stdout" --io --tcp --aio -o $tmp.csv | filter_info
echo "CSV contents" | tee -a $seq_full
cat $tmp.csv | tee -a $seq_full | filter_info
echo "CSV complete" | tee -a $seq_full
dstat "CSV instances" --cpu -C 1,2,total --cpu-use -o $tmp.csv2 | filter_info
echo "CSV instances contents" | tee -a $seq_full
cat $tmp.csv2 | tee -a $seq_full | filter_info
echo "CSV instances complete" | tee -a $seq_full
# verify no terminal size effects on CSV output
dstat "CSV terminal default" -tfvnrl -o $tmp.csvterm0 | filter_info
SAVED_TPUT_COLUMNS=80; export SAVED_TPUT_COLUMNS SAVED_COLUMNS=$COLUMNS SAVED_LINES=$LINES
test -x /usr/bin/tput && SAVED_TPUT_COLUMNS=`/usr/bin/tput cols`; export SAVED_TPUT_COLUMNS
# reduce terminal size, output should be unchanged
test -x /usr/bin/stty && /usr/bin/stty cols 40 >/dev/null 2>&1
COLUMNS=40; export COLUMNS LINES=40
dstat "CSV terminal reduced" -tfvnrl -o $tmp.csvterm1 | filter_info
echo "CSV terminal contents" | tee -a $seq_full
cat $tmp.csvterm1 | tee -a $seq_full | filter_info
echo "CSV terminal compared" | tee -a $seq_full
diff $tmp.csvterm0 $tmp.csvterm1 | tee -a $seq_full | filter_info
echo "CSV terminal complete" | tee -a $seq_full
COLUMNS=$SAVED_COLUMNS; export COLUMNS LINES=$SAVED_LINES
test -x /usr/bin/stty && /usr/bin/stty cols $SAVED_TPUT_COLUMNS >/dev/null 2>&1
unset SAVED_TPUT_COLUMNS SAVED_COLUMNS SAVED_LINES
# success, -D all done
status=0
exit
|