0
我在的zabbix JMX一個項目:
JMX [ 「MONITOR:類型=混合」,HybridInfo]
此產品返回如下字符串
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
我想秒自從上一次執行:3項類似
JMX [ 「MONITOR:類型=雜交」, 「HybridInfo」]的regexp。[(自上次執行 秒:)。([0-9] *),, \ 2])
或者這將是JMX查詢等內:
JMX [ 「MONITOR:類型=雜交」, 「HybridInfo。」 自上次執行秒:「]
爲JMX項目的測試代碼是以上。
#!/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
我想是這樣的項目:web.page.regexp [本地主機 「/ VI /健康檢查/ API1」,3345,(HTTP /1.1).([0-9]* ),, \ 2]
它會很像這個項目: web.page.regexp [localhost,「/ vi/health-check/api1」,3345,(HTTP/1.1)。([0-9] *),, \ 2] – Daniel
如前所述,Zabbix不支持將其作爲所有項目類型的通用功能 - 它是Zabbix 3.4中的一項功能。 – Richlv
@ Richlv謝謝你的回答。 – Daniel