summaryrefslogtreecommitdiff
path: root/qa/findmetric
diff options
context:
space:
mode:
Diffstat (limited to 'qa/findmetric')
-rwxr-xr-xqa/findmetric110
1 files changed, 110 insertions, 0 deletions
diff --git a/qa/findmetric b/qa/findmetric
new file mode 100755
index 0000000..9ab010a
--- /dev/null
+++ b/qa/findmetric
@@ -0,0 +1,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