3 # Exercise pmrep Zabbix export reporting modes.
5 # Copyright (c) 2015 Red Hat.
9 echo "QA output created by $seq"
13 $python -c "from pcp import pmapi" >/dev
/null
2>&1
14 [ $?
-eq 0 ] || _notrun
"python pcp pmapi module not installed"
15 $python -c "from collections import OrderedDict" >/dev
/null
2>&1
16 [ $?
-eq 0 ] || _notrun
"python collections OrderedDict module not installed"
18 which socat
>/dev
/null
2>&1 || _notrun
"socat binary not installed"
19 which pmrep
>/dev
/null
2>&1 || _notrun
"pmrep not installed"
21 status
=1 # failure is the default!
22 signal
=$PCP_BINADM_DIR/pmsignal
23 $sudo rm -rf $tmp $tmp.
* $seq.full
24 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
28 echo "--- pmrep stdout --" >>$seq.full
29 cat $tmp.pmrep.out
>>$seq.full
30 echo "--- pmrep stderr --" >>$seq.full
31 cat $tmp.pmrep.err
>>$seq.full
32 echo "--- socat stdout --" >>$seq.full
33 cat $tmp.socat.out
>>$seq.full
34 echo "--- socat stderr --" >>$seq.full
35 cat $tmp.socat.err
>>$seq.full
42 # extract the (partially binary) header, preceding the JSON response
43 # and make it into a deterministic string
48 sed -e 's/ D 001.*/ D/g'
51 zabbix_port
=`_find_free_port`
52 log
="-z --archive $here/archives/sample-secs"
54 # real QA test starts here
55 cat <<EOF >$tmp.config
57 zabbix_port = $zabbix_port
58 zabbix_host = HOSTNAME
59 zabbix_server = localhost
62 msecs = sample.milliseconds
65 cat $tmp.config
>>$seq.full
67 socat tcp-listen
:$zabbix_port,reuseaddr
- >$tmp.socat.out
2>$tmp.socat.err
&
70 pmrep
-t 2 -s 3 $log -c $tmp.config
-o zabbix sample
>$tmp.pmrep.out
2>$tmp.pmrep.err
& # will error out after socket cat dies
73 $signal $pid $pmpid 2>/dev
/null
77 echo "== Zabbix server input ==="
78 # check the first line has the initial ZBXD preamble (before JSON)
79 header
=`_zbx_header $tmp.socat.out`
80 echo "header: $header"
82 echo '{' # ate this from the header
83 sed -n '1!p' $tmp.socat.out