3 # checks basic pcp2influxdb functionality
5 # Copyright (c) 2015 Red Hat, Inc.
8 echo "QA output created by $seq"
12 $python -c "from pcp import pmapi" >/dev
/null
2>&1
13 [ $?
-eq 0 ] || _notrun
"python pcp pmapi module not installed"
14 which socat
>/dev
/null
2>&1 || _notrun
"socat binary not installed"
15 which pcp2influxdb
>$seq.full
2>&1 || _notrun
"pcp2influxdb not installed"
17 $python -c "import requests" >/dev
/null
2>&1
18 [ $?
-eq 0 ] || _notrun
"python requests module not installed"
19 major
=`$python -c 'import requests; print(requests.__version__.split(".")[0])'`
20 [ $major -ge 1 ] || _notrun
"python requests module too old (v$major)"
23 echo |
$PCP_BINADM_DIR/telnet-probe localhost
$port \
24 && _notrun
"Someone already listening on typical InfluxDB $port"
26 $sudo rm -rf $seq.full
$tmp.
*
27 signal
=$PCP_BINADM_DIR/pmsignal
28 status
=1 # failure is the default!
30 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34 echo "--- pcp2influxdb stdout --" >>$seq.full
35 cat $tmp.p2i.out
>>$seq.full
36 echo "--- pcp2influxdb stderr --" >>$seq.full
37 cat $tmp.p2i.err
>>$seq.full
38 echo "--- socket cat stdout --" >>$seq.full
39 cat $tmp.socat.out
>>$seq.full
40 echo "--- socket cat stderr --" >>$seq.full
41 cat $tmp.socat.err
>>$seq.full
45 ncpu
=`pmprobe -v hinv.ncpu | awk '{print $3*'$scale'".0"}'`
46 pcp2influxdb
="$python `which pcp2influxdb`"
48 echo |
tee -a $seq.full
49 echo "=== 1. pcp2influxdb one-shot noauth ===" |
tee -a $seq.full
50 socat tcp-listen
:$port,reuseaddr
- >$tmp.socat.out
2>$tmp.socat.err
&
53 $pcp2influxdb --database roar
-t 1 hinv.ncpu
>$tmp.p2i.out
2>$tmp.p2i.err
& # will error out after socket cat dies
56 $signal $pid $p2ipid 2>/dev
/null
58 egrep -q "^POST \/write\?db=roar" $tmp.socat.out
59 [ $?
-eq 0 ] && echo "Found POST URL in noauth output"
60 egrep -q "hinv_ncpu value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
61 [ $?
-eq 0 ] && echo "Found proper metric body in noauth output"
64 echo "=== 2. pcp2influxdb noauth with tags ===" |
tee -a $seq.full
65 socat tcp-listen
:$port,reuseaddr
- >$tmp.socat.out
2>$tmp.socat.err
&
68 $pcp2influxdb --database roar
--tag-string host=me.example.com
-t 1 hinv.ncpu \
69 >$tmp.p2i.out
2>$tmp.p2i.err
& # will error out after socket cat dies
72 $signal $pid $p2ipid 2>/dev
/null
74 egrep -q "^POST \/write\?db=roar" $tmp.socat.out
75 [ $?
-eq 0 ] && echo "Found POST URL in noauth output"
76 egrep -q "hinv_ncpu,host=me\.example\.com value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
77 [ $?
-eq 0 ] && echo "Found proper metric body in noauth output"
80 echo "=== 3. pcp2influxdb auth with tags ===" |
tee -a $seq.full
81 socat tcp-listen
:$port,reuseaddr
- >$tmp.socat.out
2>$tmp.socat.err
&
84 $pcp2influxdb --database roar
--db-user pcp
--db-password hey \
85 --tag-string host=me.example.com
-t 1 hinv.ncpu \
86 >$tmp.p2i.out
2>$tmp.p2i.err
& # will error out after socket cat dies
89 $signal $pid $p2ipid 2>/dev
/null
91 egrep -q "^POST \/write\?db=roar" $tmp.socat.out
92 [ $?
-eq 0 ] && echo "Found POST URL in output"
93 egrep -q "Authorization: Basic cGNwOmhleQ==" $tmp.socat.out
94 [ $?
-eq 0 ] && echo "Found auth data in HTTP request"
95 egrep -q "hinv_ncpu,host=me\.example\.com value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
96 [ $?
-eq 0 ] && echo "Found proper metric body in output"
99 echo "=== 4. pcp2influxdb bad-instance tolerance ===" |
tee -a $seq.full
100 rm -f $tmp.socat.out
$tmp.socat.err
101 socat tcp-listen
:$port,reuseaddr
- >>$tmp.socat.out
2>>$tmp.socat.err
&
104 $pcp2influxdb -t 2 sample.bogus_bin sample.aggregate.null sample.string.hullo NoSuchMetric sample.bad
>$tmp.p2i.out
2>$tmp.p2i.err
&
106 sleep 8 # enough for at least 2 messages
107 $signal $pid $p2ipid 2>/dev
/null
109 grep 'Excluding' $tmp.p2i.err