3 # pmlogrewrite - simple rewriting cases
5 # Copyright (c) 2011 Ken McDonell. All Rights Reserved.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 which pmlogrewrite
>/dev
/null
2>&1 || _notrun
"pmlogrewrite not installed"
18 status
=0 # success is the default!
19 $sudo rm -rf $tmp.
* $seq.full
20 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
26 -e "s/^\([+-][+-][+-] TMP\...t*\).*/\1/"
29 # 1.80.15 (disk.dev.bytes):
30 # inst [339 or "dks9d1"] value 179031
34 $2 == "(disk.dev.bytes):" { xlate=1; print; next }
35 xlate == 1 && NF == 6 { $6 = int(($6 + 512)/1024) }
37 xlate == 1 && NF != 6 { xlate = 0 }'
42 $2 == "(disk.dev.bytes):" { xlate=1; print; next }
43 xlate == 1 && NF == 6 { $6 = $6 }
45 xlate == 1 && NF != 6 { xlate = 0 }'
52 echo "Arrgh ... $1.0 missing" | _filter
57 echo "Arrgh ... $2.0 missing" | _filter
60 pmdumplog
-z -a $1 |
tee -a $seq.full
>$tmp.
in
61 pmdumplog
-z -a $2 |
tee -a $seq.full
>$tmp.out
62 echo "pmdumplog diffs ..."
63 diff -u $tmp.
in $tmp.out | _filter
64 [ -z "$filter_new" -a -z "$filter_old" ] && return
65 if [ ! -z "$filter_old" ]
67 $filter_old <$tmp.
in >$tmp.tmp
69 echo "--- after $filter_old ---" >>$seq.full
70 cat $tmp.tmp
>>$seq.full
73 if [ ! -z "$filter_new" ]
75 $filter_new <$tmp.out
>$tmp.tmp
77 echo "--- after $filter_new ---" >>$seq.full
78 cat $tmp.tmp
>>$seq.full
82 echo "FILTERED pmdumplog diffs ..."
83 diff -u $tmp.
in $tmp.out | _filter
86 # real QA test starts here
87 sed -e '/^#/d' <<End-of-File | while read arch_args spec
88 # archive[|arg1[|arg2[|...]]] spec
89 # rewrite pmDesc and pmid in pmResults
90 archives/mirage metric sample.bin { pmid->42.42.42 }
91 # name is 3 bytes shorter
92 archives/mirage metric sample.bin { name -> sam.bin }
93 # name is 10 bytes longer
94 archives/mirage metric sample.bin { name -> x23456789.sample.bin }
96 archives/mirage indom 29.2 { inst 300 -> 42 }
97 archives/mirage indom 29.2 { inst 300 -> 400 }
98 archives/mirage indom 29.2 { iname "bin-700" -> "bin-900" }
99 archives/mirage indom 29.2 { iname "bin-700" -> "bin-900 and some" }
100 archives/mirage indom 29.2 { iname "bin-300" -> "bin-100" inst 300 -> 100 }
101 archives/src-rattle indom 1.5 { iname "1 minute" -> "5" }
102 archives/src-rattle indom 1.5 { iname "5 minute" -> "15 doo dah" }
103 archives/src-rattle indom 1.5 { iname "5" -> "5 hours" }
104 # all metric semantics
105 archives/mirage metric 29.*.* { sem->DISCRETE } metric pmcd.pmlogger.port { sem->COUNTER }
107 archives/src-snort-disks metric disk.dev.bytes { units->1,0,0,MBYTE,0,0 }
108 archives/src-snort-disks|-s metric disk.dev.bytes { units->1,0,0,MBYTE,0,0 }
109 archives/src-snort-disks metric disk.dev.bytes { units->1,-1,0,Kbyte,Sec,0 }
110 archives/src-snort-disks|-ws metric disk.dev.bytes { units->1,-1,0,kbyte,sec,0 }
111 archives/sample_expr metric sample.scale_step.time_up_secs { units->0,1,0,0,MSEC,0 }
114 archives/mirage metric sample.drift { type -> U32 }
115 archives/mirage metric sample.drift { type -> 64 }
117 archives/sample_expr metric sample.scale_step.time_up_secs { type -> FLOAT }
118 archives/sample_expr metric sample.scale_step.time_up_secs { type -> U32 }
120 archives/src-rattle metric pmcd.pmlogger.archive { indom -> 2.99 } indom 2.1 { indom -> 2.99 }
121 archives/src-rattle metric hinv.ndisk { indom -> 1.5 }
122 archives/src-rattle metric hinv.ndisk { indom -> 1.5 output inst 5 }
123 archives/ok-foo metric sample.colour { indom -> NULL }
124 archives/ok-foo metric sample.colour { indom -> NULL output first }
125 archives/ok-foo metric sample.colour { indom -> NULL output inst 1 }
126 archives/ok-foo metric sample.colour { indom -> NULL output last }
127 archives/ok-foo metric sample.colour { indom -> NULL output min }
128 archives/ok-foo metric sample.colour { indom -> NULL output max }
129 archives/ok-foo metric sample.colour { indom -> NULL output sum }
130 archives/ok-foo metric sample.colour { indom -> NULL output avg }
131 archives/sample_expr metric sample.mirage_longlong {indom->NULL}
132 archives/sample_expr metric sample.mirage_longlong {indom->NULL output last}
135 echo |
tee -a $seq.full
136 echo "$spec" >$tmp.config
137 echo "=== `cat $tmp.config` ===" |
tee -a $seq.full
139 arch
=`echo "$arch_args" | sed -e 's/|.*//'`
140 args
=`echo "$arch_args" | sed -n -e '/|/s/.*|//p'`
141 pmlogrewrite
-w -c $tmp.config
$args $arch $tmp.new
2>&1 | _filter
146 'archives/src-snort-disks|-s')