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
|
#! /bin/sh
# PCP QA Test No. 096
# proc.psinfo.ttyname
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.product
. ./common.check
. ./common.filter
if [ $PCP_PLATFORM = darwin -o $PCP_PLATFORM = solaris ]
then
_notrun "No proc metrics for $PCP_PLATFORM"
else
# proc metrics may not be available
#
if pminfo proc.nprocs >/dev/null 2>&1
then
:
else
_notrun proc PMDA not installed
fi
fi
trap "rm -f $tmp.*; exit" 0 1 2 3 15
# real QA test starts here
if [ $# -eq 1 ]
then
if [ $1 = "-v" ]
then
verbose=1
fi
fi
# make sure we have latest ttymap
$sudo rm -f $seq.full
$sudo rm -f /tmp/pcp.ttymap
# make sure proc agent reloads it
$sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
_wait_for_pmcd
_wait_for_pmlogger
#
# tty filtering per host
#
if [ $PCP_PLATFORM = irix ]
then
# handle stupid /dev/tablet as controlling tty!
ls -lr /dev | grep '^c.* 0, 1' \
| $PCP_AWK_PROG '
NR == 1 { good=$NF; next }
{ print "s/" $NF "/" good "/" }' >$tmp.sed
ps -e | tee -a $seq.full |\
sed -e 's#pts/#ttyq#' |
sed -f $tmp.sed > $tmp.ps
elif [ $PCP_PLATFORM = linux ]
then
ps -e | tee -a $seq.full | sed \
-e 's#ttyS#tts/#' \
| $PCP_AWK_PROG '
/<defunct>/ { print $1, "?" }
{print}' >$tmp.ps
else
echo "Arrgh ... Need to know how to do tty filtering for $PCP_PLATFORM"
exit 1
fi
echo "=====================" >>$seq.full
pminfo -F proc.psinfo.ttyname |\
sed > $tmp.pminfo \
-e '/DISAPPEARED/d' \
-e 's#"ttyS#"tts/#' \
-e 's#vc/#tty#'
echo "----" > $tmp.sep
maxfailures=0
cat $tmp.ps $tmp.sep $tmp.pminfo | tee -a $seq.full |\
$PCP_AWK_PROG -v verbose=$verbose -v maxfailures=$maxfailures -v failfile=$tmp.fail '
$0 == "----" { pminfo = 1; next; }
pminfo == 0 {
# handle defunct processes which have "-" as tty
if ($2 == "-")
$2 = "?"
ps[$1] = $2
ps_cmd[$1] = $4
next
}
/ inst \[/ {
sub(/.* inst \[/, "") # delete up to [
pid = $1
# fall-through, expect value on same line, but not
# not necessarily so
}
/] value "/ {
sub(/.*] value "/, "") # delete up to value "
sub(/"/,"") # delete the final "
value = $1;
# do the comparison
if (pid in ps) {
if (ps[pid] != value && value != "?") {
printf("mismatch: pid = %s, ps = %s, proc = %s, cmd = %s\n", pid, ps[pid], value, ps_cmd[pid]) > failfile;
failures++;
}
else if (verbose == 1) {
printf("match for pid = %d, value = %s, ps[pid] = %s, cmd = %s\n", pid, value, ps[pid], ps_cmd[pid]);
}
}
}
END {
if (failures > maxfailures) {
printf("Number of failures = %d\n", failures)
system("cat " failfile)
}
else
printf("proc.psinfo.ttyname matches with ps\n")
}
'
echo
echo "If failure, check $seq.full"
exit 0
|