#!/bin/sh
# PCP QA Test No. 883
# Excercise pcp mpstat for an archive
#
# Copyright (c) 2016 [Sitaram Shelke].  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

status=1	# failure is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
trap "cd $here; rm -rf $tmp $tmp.*; exit \$status" 0 1 2 3 15

pcp_mpstat="$PCP_BINADM_DIR/pcp-mpstat"
test -x $pcp_mpstat || _notrun "No pcp-mpstat(1) installed"

pcp_mpstat="$python $pcp_mpstat"
pcp_archive="-z -a archives/pcp-mpstat"
pcp_archive2="-z -a archives/pcp-mpstat2"

# real QA test starts here
export LC_TIME=POSIX

echo && echo === pcp-mpstat without any options
pcp $pcp_archive mpstat

echo && echo === pcp-mpstat with cpu filter 
pcp $pcp_archive mpstat -P 1,2

echo && echo === pcp-mpstat total interrupt usage without any options
pcp $pcp_archive mpstat -I SUM

echo && echo === pcp-mpstat total interrupt usage with online cpus
pcp $pcp_archive mpstat -I SUM -P ON

echo && echo === pcp-mpstat soft interrupt usage with two samples
pcp $pcp_archive mpstat -I SCPU -s 2

echo && echo === pcp-mpstat soft interrupt usage with all cpus
pcp $pcp_archive mpstat -I SCPU -P ALL

echo && echo === pcp-mpstat hard interrupt usage with interval count 2 sec
pcp $pcp_archive mpstat -I CPU

echo && echo === pcp-mpstat hard interrupt usage with cpu filter
pcp $pcp_archive mpstat -I CPU -P 0,2

echo && echo === pcp-mpstat all interrupt usages
pcp $pcp_archive mpstat -I ALL

echo && echo === pcp-mpstat with all reports 
pcp $pcp_archive mpstat -I SCPU

echo && echo === pcp-mpstat without options nor interrupt metrics
pcp $pcp_archive2 mpstat

echo && echo === pcp-mpstat soft interrupt usage without metrics
pcp $pcp_archive2 mpstat -I SCPU -s 2

echo && echo === pcp-mpstat hard interrupt usage without metrics
pcp $pcp_archive2 mpstat -I CPU -s 2

# success, all done
status=0
exit
