1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
|
#!/bin/sh
# PCP QA Test No. 1067
# Exercise the zbxpcp Zabbix integration module.
#
# Copyright (c) 2015 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
which zabbix_agentd >/dev/null 2>&1 || \
_notrun "No zabbix_agentd binary found"
test -f /etc/zabbix/zabbix_agentd.conf || \
_notrun "No configuration for the Zabbix agent daemon"
test -f /etc/zabbix/zabbix_agentd.d/zbxpcp.conf || \
_notrun "Zabbix agent PCP module is not installed"
# zabbix_agentd goes off with the pixies on vm21 after upgrading to
# Debian 12 (uses all cpu cycles, mostly in system mode) ... not our
# problem and not worth the triage bandwidth to investigate
#
case `admin/whatami`
in
*Debian\ 12.*)
_notrun "avoid zabbix_agentd locking up the system Debian 12.?"
;;
esac
rm -f $seq.out
# Known versions ...
# Zabbix Agent (daemon) v2.2.7 (revision 50148) (24 October 2014)
# - no [error message] after [.|ZBX_NOTSUPPORTED]
# zabbix_agentd (daemon) (Zabbix) 3.0.7
# - [error message] after [.|ZBX_NOTSUPPORTED]
#
version=`zabbix_agentd -V | sed -n -e '/^[Zz]abbix/{
s/ v/ /
s/^[^0-9]* \([0-9]\)/\1/
s/ .*//
p
}'`
case "$version"
in
1.*)
_notrun "zabbix_agentd $version too old (no LoadModulePath config option)"
;;
2.[0-2].*)
ln $seq.out.0 $seq.out
;;
2.4.*|3.*|4.*|5.*|6.*|7.*)
ln $seq.out.1 $seq.out
;;
*) echo "Botch: need to know what output to expect for zabbix_agent version $version"
exit 1
;;
esac
case "$PCP_PLATFORM"
in
darwin)
ZBXPCP=zbxpcp.dylib; export ZBXPCP
;;
mingw)
ZBXPCP=zbxpcp.dll; export ZBXPCP
;;
*)
ZBXPCP=zbxpcp.so; export ZBXPCP
;;
esac
status=1 # failure is the default!
need_control=false
need_derived=false
control=$PCP_PMDAS_DIR/sample/dynamic.indom
derived=/etc/zabbix/zbxpcp-derived-metrics.conf
echo "zabbix_agentd version: $version" >>$seq_full
_cleanup()
{
$need_control && _restore_config $control
$need_derived && _restore_config $derived
rm -f $tmp.*
}
trap "_cleanup; exit \$status" 0 1 2 3 15
if [ -f $control ]
then
need_control=true
_save_config $control
fi
if [ -f $derived ]
then
need_derived=true
_save_config $derived
fi
# pcp.sample.float.hundred [d|100.000000]
# pcp.sample.double.ten [d|10.000000]
# the decimal part may not be reported^^^^^^
#
_filter_float()
{
sed \
-e '/pcp.sample.float.hundred/s/100\.00*/100/' \
-e '/pcp.sample.double.ten/s/10\.00*/10/' \
# end
}
_filter_values()
{
# expect lines like:
# pcp.sample.dodgey.control [u|5]
# pcp.sample.dodgey.value[d1] [u|35]
# pcp.sample.bad.novalues [m|ZBX_NOTSUPPORTED] [No value available.]
# d|u|s -> zabbix types;
# m is error encodings -> allow through
sed \
-e 's/\[[dus]|.*\]$/VALUE/g' \
-e '/sample\.scramble/d' \
#end
}
cat <<EOF > $tmp.conf
LoadModulePath=$PCP_LIB_DIR/zabbix/modules
LoadModule=$ZBXPCP
# for rpm -qa if repo cache needs refreshing
Timeout=30
EOF
echo "zabbix_agentd config:" >>$seq_full
cat $tmp.conf >>$seq_full
# need the sample.proc metricss to be deterministic
pmstore sample.proc.reset 1
# real QA test starts here
zabbix_agentd="zabbix_agentd -c $tmp.conf"
echo "== request specific values"
# verify values for single metrics/instances
$zabbix_agentd -t pcp.sample.long.one
$zabbix_agentd -t 'pcp.sample.long.bin[bin-100]'
$zabbix_agentd -t pcp.sample.ulonglong.million
$zabbix_agentd -t pcp.sample.float.hundred | _filter_float
$zabbix_agentd -t pcp.sample.double.ten | _filter_float
# string metrics
$zabbix_agentd -t pcp.sample.string.null
$zabbix_agentd -t pcp.sample.string.hullo
# aggregate/event metrics
$zabbix_agentd -t pcp.sample.aggregate.hullo
$zabbix_agentd -t 'pcp.sample.event.records[fungus]'
# other error cases
$zabbix_agentd -t pcp.sample.bad.nosupport
$zabbix_agentd -t pcp.sample.bad.novalues
# verify enumeration of all metrics
echo "== enumerated names and filtered values" | tee -a $seq_full
pmstore sample.ghosts.visible "-1" >>$seq_full 2>&1
$sudo rm -f $control # control the dynamic indom
echo '1 one' >$tmp.indom
echo '2 two' >>$tmp.indom
$sudo cp $tmp.indom $control
$zabbix_agentd -p \
| tee -a $seq_full \
| grep -F pcp.sample. \
| _filter_values
# derived metrics
echo "== check derived metric configuration"
echo mem.util.allcache = mem.util.cached + mem.util.slab | tee $tmp.derived
echo sample.derived.hundredten = sample.float.hundred + sample.double.ten | tee -a $tmp.derived
$sudo cp $tmp.derived $derived
$zabbix_agentd -t pcp.mem.util.allcache | _filter_values
$zabbix_agentd -t pcp.sample.derived.hundredten | _filter_values
$sudo rm -f $control $derived
# success, all done
status=0
exit
|