Usage example • zabbix-jmx-get • CI Status • License
zabbix-jmx
is a Go package for retrieving and parsing data from Zabbix Java Gateway.
package main
import (
"fmt"
jmx "github.com/essentialkaos/go-zabbix-jmx"
)
func main() {
client, err := jmx.NewClient("127.0.0.1:9335")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
r := &jmx.Request{
Server: "domain.com",
Port: 9093,
Username: "admin",
Password: "admin",
Keys: []string{`jmx["kafka.server:type=ReplicaManager,name=PartitionCount",Value]`},
}
resp, err := client.Get(r)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Resp value: %s\n", resp[0].Value)
}
We also provide a command-line tool zabbix-jmx-get
for retrieving data from Zabbix Java Gateway.
From sources:
go install github.com/essentialkaos/go-zabbix-jmx/cmd/zabbix-jmx-get@latest
Prebuilt binaries:
bash <(curl -fsSL https://apps.kaos.st/get) zabbix-jmx-get
$ zabbix-jmx-get 127.0.0.1 10052 kfk-node1.domain.com 9093 'jmx.discovery[beans,"*:type=BrokerTopicMetrics,name=*"]'
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=TotalProduceRequestsPerSec TotalProduceRequestsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=BytesOutPerSec BytesOutPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec BytesInPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=BytesRejectedPerSec BytesRejectedPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=FailedProduceRequestsPerSec FailedProduceRequestsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=FetchMessageConversionsPerSec FetchMessageConversionsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec MessagesInPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=FailedFetchRequestsPerSec FailedFetchRequestsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=ProduceMessageConversionsPerSec ProduceMessageConversionsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=ReplicationBytesInPerSec ReplicationBytesInPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=TotalFetchRequestsPerSec TotalFetchRequestsPerSec
kafka.server BrokerTopicMetrics kafka.server:type=BrokerTopicMetrics,name=ReplicationBytesOutPerSec ReplicationBytesOutPerSec
$ zabbix-jmx-get 127.0.0.1 10052 kfk-node1.domain.com 9093 'jmx["kafka.server:type=BrokerTopicMetrics,name=BytesInPerSec",OneMinuteRate]'
5668479.780357378
Branch | Status |
---|---|
master |
|
develop |