Good afternoon
I have a item in Zabbix JMX:
jmx["MONITOR:type=Hybrid",HybridInfo]
This item returns the follow string
POOL: HYBRID-CHARGE.I8
Active: true
Carrier: TIM
Start Producer: true
Start Consumer: true
Configurations: null
CONSUMER
Consumer Threads: 23
Scheduled Tasks: 50
PRODUCER
Objects: 50000
Pagination Table: temporary.hybrid_engine_4
Pagination Interval: 60
Last Database Query: Fri May 12 14:23:32 UTC 2017
Last Result Size: 923526
Last Row Read: 923526
Seconds since Last Execution: 3
I want to get Seconds since Last Execution: 3 in the item like
jmx["MONITOR:type=Hybrid","HybridInfo"].regexp[(Seconds since Last Execution:).([0-9]*),,\2])
Or it would be inside the JMX query like:
jmx["MONITOR:type=Hybrid","HybridInfo."Seconds since Last Execution:"]
The test code for the JMX item is above.
#!/usr/bin/env bash
# Original source: https://www.zabbix.org/wiki/Docs/howto/zabbix_get_jmx
# Requires 'nc' app
ZBXGET="/usr/bin/zabbix_get"
if [ $# != 5 ] && [ $# != 7 ]; then
echo "Usage: $0 <JAVA_GATEWAY_HOST> <JAVA_GATEWAY_PORT> <JMX_SERVER> <JMX_PORT> <KEY> [<JMX_USER> <JMX_PASS>]"
exit;
fi
# Escape backslashes and double-quotes
KEYS=$(echo $5 | sed -e 's/\\/\\\\\\\\/g' -e 's/"/\\\"/g')
if [ $# = 5 ]; then
QUERY="{\"request\": \"java gateway jmx\",\"conn\": \"$3\",\"port\": $4,\"keys\": [\"${KEYS}\"]}"
else
JMX_USER="$6"
JMX_PASS="$7"
QUERY="{\"request\": \"java gateway jmx\",\"conn\": \"$3\",\"port\": $4,\"keys\": [\"${KEYS}\"],\"username\": \"${JMX_USER}\",\"password\": \"${JMX_PASS}\"}"
fi
# Prefix with binary header and length
QUERY_INTERPRETED=$(echo -en "${QUERY}")
QUERY_LEN=${#QUERY_INTERPRETED}
QUERY_LEN_BIN=$(printf "%.16x" ${QUERY_LEN} | sed "s/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\\\x\8\\\x\7\\\x\6\\\x\5\\\x\4\\\x\3\\\x\2\\\x\1/")
QUERY_BIN="ZBXD\x01${QUERY_LEN_BIN}${QUERY}"
# Could not get zabbix_get 3.2.3 to work due to ZBX-11528 changes
# $ZBXGET -s $1 -p $2 -k "$QUERY"
echo -en "${QUERY_BIN}" | nc $1 $2
I would like something like this item: web.page.regexp[localhost,"/vi/health-check/api1",3345,(HTTP/1.1).([0-9]*),,\2]
Not sure what test code is there, or how is the shell script related, but item value parsing in Zabbix is not supported yet, it is coming for Zabbix 3.4: https://support.zabbix.com/browse/ZBXNEXT-1443 .