zabbix-jmx.v1: pkg.re/essentialkaos/zabbix-jmx.v1 Index | Examples | Files

package jmx

import "pkg.re/essentialkaos/zabbix-jmx.v1"

Package zabbix-jmx provides methods for working with Zabbix Java Gateway

Index

Examples

Package Files

beans.go protocol.go zabbix.go

type Bean Uses

type Bean struct {
    Domain string `json:"{#JMXDOMAIN}"`
    Type   string `json:"{#JMXTYPE}"`
    Object string `json:"{#JMXOBJ}"`
    Name   string `json:"{#JMXNAME}"`
}

Bean contains basic bean info

func ParseBeans Uses

func ParseBeans(data string) ([]*Bean, error)

ParseBeans parses beans data

type Client Uses

type Client struct {
    ConnectTimeout time.Duration
    WriteTimeout   time.Duration
    ReadTimeout    time.Duration
    // contains filtered or unexported fields
}

Client is Zabbix JMX client

func NewClient Uses

func NewClient(address string) (*Client, error)

NewClient creates new client

Code:

client, err := NewClient("127.0.0.1:9335")

if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
}

client.WriteTimeout = time.Second * 3
client.ReadTimeout = time.Second * 3

func (*Client) Get Uses

func (c *Client) Get(r *Request) (Response, error)

Get fetches data from Java Gateway

Code:

client, err := NewClient("127.0.0.1:9335")

if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
}

r := &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)

type Request Uses

type Request struct {
    Server   string
    Port     int
    Username string
    Password string
    Keys     []string
}

Request is basic request struct

type Response Uses

type Response []*ResponseData

Response contains response data

type ResponseData Uses

type ResponseData struct {
    Value string `json:"value"`
}

ResponseData contains value for requested key

Package jmx imports 9 packages (graph). Updated 2020-06-11. Refresh now. Tools for package owners.