summaryrefslogtreecommitdiff
path: root/qa/findmetric
blob: 9ab010a26ac1f4a01e7f6a4867c5bdf34e1460d8 (plain)
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
#!/bin/sh
#
# find metrics in the QA archives
#
# command line args are alternate patterns matched in the output
# from pminfo -d ... so metric names and metric descriptors
#

tmp=/var/tmp/$$
sts=0
trap "rm -f $tmp.*; exit \$sts" 0 1 2 3 15

_usage()
{
    echo >&2 "Usage: `basename $0` [options] pat ..."
    echo >&2 "   -a         search archives [default]"
    echo >&2 "   -h         search localhost live metrics"
}

arch=true
while getopts "ah?" c
do
    case $c
    in
	a)
	    arch=true
	    ;;
	h)
	    arch=false
	    ;;
	?)
	    _usage
	    sts=1
	    exit
	    ;;
    esac
done
shift `expr $OPTIND - 1`

if [ $# -eq 0 ]
then
    _usage
    sts=1
    exit
fi

pat=""
for arg
do
    if [ -z "$pat" ]
    then
	pat="($arg)"
    else
	pat="$pat|($arg)"
    fi
done

if $arch
then
    srclist="`echo src/*.0`"
else
    srclist='ignoreme'
fi

for src in $srclist
do
    if $arch
    then
	pminfo -d -a $src 2>&1
    else
	pminfo -d 2>&1
    fi \
    | sed -e '/^[a-z]/{
s/$/|/
N
s/$/|/
N
s/|./|/g
s/  */ /g
s/| Data Type: /|/
s/ InDom: /|/
s/ Semantics: /|/
s/ Units: /|/
}' \
    | egrep "$pat" >$tmp.out

    if [ -s $tmp.out ]
    then
	if $arch
	then
	    pmdumplog -l $src >$tmp.info
	    vers=`sed -n <$tmp.info -e '/Log Format Version/{
s/.*Version //
s/)//
p
}'`
	    host=`sed -n <$tmp.info -e '/ from host /{
s/.* from host //
p
}'`
	    echo "=== `basename $src .0` (V.$vers) host: $host ==="
	    grep commencing $tmp.info
	    grep ending $tmp.info
	    sed <$tmp.out -e "s/^/    /"
	else
	    echo "=== `hostname` ==="
	    sed <$tmp.out -e "s/^/    /"
	fi
    fi
done