3 # Exercise pmrep Zabbix export reporting modes.
5 # Copyright (c) 2015 Red Hat.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 which socat
>/dev
/null
2>&1 || _notrun
"socat binary not installed"
17 which pmrep
>/dev
/null
2>&1 || _notrun
"pmrep not installed"
19 status
=1 # failure is the default!
20 signal
=$PCP_BINADM_DIR/pmsignal
21 $sudo rm -rf $tmp $tmp.
* $seq.full
22 trap "cd $here; rm -rf $tmp.*; exit \$status" 0 1 2 3 15
26 echo "--- pmrep stdout --" >>$seq.full
27 cat $tmp.pmrep.out
>>$seq.full
28 echo "--- pmrep stderr --" >>$seq.full
29 cat $tmp.pmrep.err
>>$seq.full
30 echo "--- socat stdout --" >>$seq.full
31 cat $tmp.socat.out
>>$seq.full
32 echo "--- socat stderr --" >>$seq.full
33 cat $tmp.socat.err
>>$seq.full
40 # extract the (partially binary) header, preceding the JSON response
41 # and make it into a deterministic string
46 sed -e 's/ D 001.*/ D/g'
49 zabbix_port
=`_find_free_port`
50 log
="-z --archive $here/archives/sample-secs"
52 # real QA test starts here
53 cat <<EOF >$tmp.config
55 zabbix_port = $zabbix_port
56 zabbix_host = HOSTNAME
57 zabbix_server = localhost
60 msecs = sample.milliseconds
63 cat $tmp.config
>>$seq.full
65 socat tcp-listen
:$zabbix_port,reuseaddr
- >$tmp.socat.out
2>$tmp.socat.err
&
68 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
71 $signal $pid $pmpid 2>/dev
/null
75 echo "== Zabbix server input ==="
76 # check the first line has the initial ZBXD preamble (before JSON)
77 header
=`_zbx_header $tmp.socat.out`
78 echo "header: $header"
80 echo '{' # ate this from the header
81 sed -n '1!p' $tmp.socat.out