pmrep: fix archive end time reporting
[pcp.git] / qa / findmetric
blob8cf8d8766e3d456cbdd30914dfcb23bf4b5f1a26
1 #!/bin/sh
3 # find metrics in the QA archives
5 # command line args are alternate patterns matched in the output
6 # from pminfo -d ... so metric names and metric descriptors
9 tmp=/var/tmp/$$
10 sts=0
11 trap "rm -f $tmp.*; exit \$sts" 0 1 2 3 15
13 _usage()
15 echo >&2 "Usage: `basename $0` [options] pat ..."
16 echo >&2 " -a search archives [default]"
17 echo >&2 " -h search localhost live metrics"
20 arch=true
21 while getopts "ah?" c
23 case $c
26 arch=true
29 arch=false
32 _usage
33 sts=1
34 exit
36 esac
37 done
38 shift `expr $OPTIND - 1`
40 if [ $# -eq 0 ]
41 then
42 _usage
43 sts=1
44 exit
47 pat=""
48 for arg
50 if [ -z "$pat" ]
51 then
52 pat="($arg)"
53 else
54 pat="$pat|($arg)"
56 done
58 if $arch
59 then
60 srclist="`echo src/*.0 archives/*.0`"
61 else
62 srclist='ignoreme'
65 for src in $srclist
67 if $arch
68 then
69 pminfo -d -a $src 2>&1
70 else
71 pminfo -d 2>&1
72 fi \
73 | sed -e '/^[a-z]/{
74 s/$/|/
76 s/$/|/
78 s/|./|/g
79 s/ */ /g
80 s/| Data Type: /|/
81 s/ InDom: /|/
82 s/ Semantics: /|/
83 s/ Units: /|/
84 }' \
85 | egrep "$pat" >$tmp.out
87 if [ -s $tmp.out ]
88 then
89 if $arch
90 then
91 pmdumplog -l $src >$tmp.info
92 vers=`sed -n <$tmp.info -e '/Log Format Version/{
93 s/.*Version //
94 s/)//
96 }'`
97 host=`sed -n <$tmp.info -e '/ from host /{
98 s/.* from host //
101 echo "=== `basename $src .0` (V.$vers) host: $host ==="
102 grep commencing $tmp.info
103 grep ending $tmp.info
104 sed <$tmp.out -e "s/^/ /"
105 else
106 echo "=== `hostname` ==="
107 sed <$tmp.out -e "s/^/ /"
110 done