pmrep: fix archive end time reporting
[pcp.git] / qa / 128
blobb41a9600a9d839b500f506047f79b1941976b900
1 #! /bin/sh
2 # PCP QA Test No. 128
3 # Check NFS Server and Client stats (v2 and v3)
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 if [ $PCP_PLATFORM = darwin -o $PCP_PLATFORM = solaris ]
17 then
18 _notrun "no nfs metrics for $PCP_PLATFORM"
21 trap "rm -f $tmp.*; exit" 0 1 2 3 15
22 signal=$PCP_BINADM_DIR/pmsignal
24 get_pminfo()
26 perl -e '
27 open STATS, "pminfo -f '$1' |" || die "pminfo: $!";
28 while (<STATS>) {
29 s/readdir\+/readdirplus/g;
30 if (m/.*"(\S+)"] value (\d+)/) {
31 printf("'$2'_%s %d\n", $1, $2);
34 close STATS;
38 get_nfsstat()
40 perl -e '
41 $prefix = "";
42 open STATS, "nfsstat -n |" || die "nfsstat: $!";
43 while (<STATS>) {
44 if (m/server nfs v2/i) { $prefix = "nfs2_server_reqs_"; }
45 elsif (m/server nfs v3/i) { $prefix = "nfs3_server_reqs_"; }
46 elsif (m/client nfs v2/i) { $prefix = "nfs2_client_reqs_"; }
47 elsif (m/client nfs v3/i) { $prefix = "nfs3_client_reqs_"; }
48 # NFSv4 unsupported. Reset prefix to "" to ensure
49 # that NFSv4 stats are not incorrectly attributed to
50 # another NFS version.
51 elsif (m/client nfs v4/i) { $prefix = ""; }
52 elsif (m/server nfs v4/i) { $prefix = ""; }
53 elsif ($prefix eq "") { next; }
54 elsif (m/((\d+)\s+\d+%)+/g) {
55 @values = split(/\s+/);
56 #print "found - @values, @instances\n";
57 for ($i = 0; $i <= $#instances; $i++) {
58 print $prefix, $instances[$i], " ", $values[$i*2], "\n";
61 elsif (m/((\S+)\s+)+/g) {
62 #print "instances - $_\n";
63 @instances = split(/\s+/);
66 close STATS;
70 # real QA test starts here
72 # if we can find a nfs loop-back mount, go hammer on it for a while
74 mnt=''
75 [ -d /hosts/localhost/usr ] && mnt=/hosts/localhost/usr
77 cat > $tmp.workload << EOF
78 ls -R /$mnt >/dev/null 2>/dev/null &
79 KILL_PID=\$!
80 sleep 3
81 $signal -s KILL \$KILL_PID >/dev/null 2>&1
82 EOF
83 chmod u+x $tmp.workload
85 $tmp.workload >/dev/null 2>&1
86 sleep 2
88 rm -f $tmp.info $tmp.stat $tmp.join $seq.full $tmp.info2 $tmp.stat2
90 echo | tee -a $seq.full
91 echo "fetching nfsstat values..." | tee -a $seq.full
92 get_nfsstat 2>$tmp.err | tee -a $seq.full >$tmp.stat
93 LC_COLLATE=POSIX sort -d < $tmp.stat > $tmp.stat2
94 ( echo "stderr from get_nfsstat ..."; cat $tmp.err ) >>$seq.full
96 echo | tee -a $seq.full
97 echo "fetching pminfo values..." | tee -a $seq.full
98 get_pminfo nfs.server.reqs nfs2_server_reqs | tee -a $seq.full >$tmp.info
99 get_pminfo nfs3.server.reqs nfs3_server_reqs | tee -a $seq.full >>$tmp.info
100 get_pminfo nfs.client.reqs nfs2_client_reqs | tee -a $seq.full >>$tmp.info
101 get_pminfo nfs3.client.reqs nfs3_client_reqs | tee -a $seq.full >>$tmp.info
102 LC_COLLATE=POSIX sort -d < $tmp.info > $tmp.info2
104 echo | tee -a $seq.full
105 echo "comparing all values... (details in $seq.full)" | tee -a $seq.full
106 LC_COLLATE=POSIX join $tmp.info2 $tmp.stat2 | while read metric nfsvalue pmvalue
108 _within_tolerance $metric $nfsvalue $pmvalue 2% -v >>$seq.full
109 [ $? -eq 1 ] && echo failed cross check on $metric: $nfsvalue $pmvalue
110 done
111 echo done