go_jolokia

package module
v0.0.0-...-3cd2b3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2019 License: MIT Imports: 7 Imported by: 8

README

go_jolokia

< go_jolokia >
 --------
   \
    \   
       _____  -----------------  _____
      |     \/  ----     ----  \/     |
       \  ==/  /    |   |    \  \==  /
        \--/  | ()  |   |()   |  \--/
          /    \---/ ___ \---/    \
         |         _(===)_         |
        |         (__/--\__)        |
         |          |_||_|         |
          \                       /   

go_jolokia is a Simple jolokia JMX/HTTP wrapper for Go. It supports jolokia proxy setup as well as direct host connection.

GoDoc

Version

0.1.0

Usage
Step 1 : Get It

To get the go_jolokia install Go and execute the below command

go get github.com/swarvanusg/go_jolokia
Step 2 : Initiate a client
client := NewJolokiaClient("http://" + proxyhost + ":" + proxyport + "/" + jolokia)

client.SetTarget(targetHost + ":" + targetPort)
Step 3 : Use the client for Getting Info
beans, err := client.ListBeans("java.lang")

props, err := client.ListProperties("java.lang", []string{"type=Threading"})

val, err := client.GetAttr("java.lang", []string{"type=Threading"}, "PeakThreadCount")
Current Status:

The go_jolokia build is success The test cases are passing

Inspired from

github.com/cmceniry/golokia

Documentation

Overview

Maintainer Swarvanu Sengupta <swarvanusg@gmail.com>.

Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.

Index

Constants

View Source
const (
	// READ for read operation
	READ = "READ"
	// LIST for list operation
	LIST = "LIST"
	// EXEC for exec operation
	EXEC = "EXEC"
)

ENUM to be used

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecRequestData

type ExecRequestData struct {
	Type      string      `json:"type"`
	Mbean     string      `json:"mbean"`
	Operation string      `json:"operation"`
	Arguments interface{} `json:"arguments"`
	Target    `json:"target"`
}

The wrapper structure for an EXEC json request

type JolokiaClient

type JolokiaClient struct {
	// contains filtered or unexported fields
}

Jolokia Client properties connecting a Jolokia agent

func NewJolokiaClient

func NewJolokiaClient(jolokiaUrl string) *JolokiaClient

Creates a Jolokia Client for a specific url e.g. "http://127.0.0.1:8080/jolokia"

func (*JolokiaClient) ExecuteOperation

func (jolokiaClient *JolokiaClient) ExecuteOperation(mBean, operation string, arguments interface{}, pattern string) (*JolokiaReadResponse, error)

Executes a jolokia operation execution request using a jolokia client and return response

func (*JolokiaClient) ExecuteReadRequest

func (jolokiaClient *JolokiaClient) ExecuteReadRequest(jolokiaRequest *JolokiaRequest) (*JolokiaReadResponse, error)

Executes a jolokia read request using a jolokia client and return response

func (*JolokiaClient) ExecuteRequest

func (jolokiaClient *JolokiaClient) ExecuteRequest(jolokiaRequest *JolokiaRequest, pattern string) (*JolokiaResponse, error)

Executes a jolokia request using a jolokia client and return response

func (*JolokiaClient) GetAttr

func (jolokiaClient *JolokiaClient) GetAttr(domain string, properties []string, attribute string) (interface{}, error)

Get a attribute value of a specific property of an bean and a domain using a jolokia client

func (*JolokiaClient) ListBeans

func (jolokiaClient *JolokiaClient) ListBeans(domain string) ([]string, error)

List the beans of a specific domain using a jolokia client and return response

func (*JolokiaClient) ListDomains

func (jolokiaClient *JolokiaClient) ListDomains() ([]string, error)

List the domains using a jolokia client and return response

func (*JolokiaClient) ListProperties

func (jolokiaClient *JolokiaClient) ListProperties(domain string, properties []string) ([]string, error)

List the properties of a specific bean and domain using a jolokia client and return response

func (*JolokiaClient) SetCredential

func (jolokiaClient *JolokiaClient) SetCredential(userName string, pass string)

Set access credential to Jolokia client

func (*JolokiaClient) SetTarget

func (jolokiaClient *JolokiaClient) SetTarget(targetHost string)
Set target host when jolokia agent working in proxy architecture e.g. "10.0.1.96:7911"

(see: https://jolokia.org/reference/html/proxy.html)

func (*JolokiaClient) SetTargetCredential

func (jolokiaClient *JolokiaClient) SetTargetCredential(userName string, pass string)

Set target host access credential to Jolokia client

type JolokiaReadResponse

type JolokiaReadResponse struct {
	// Status of the request
	Status uint32
	// Timestamp value
	Timestamp uint32
	// Request
	Request map[string]interface{}
	// Result value
	Value interface{}
	// Error
	Error string
}

Jolokia Response for Read request

type JolokiaRequest

type JolokiaRequest struct {
	// contains filtered or unexported fields
}

Jolokia Request properties

func NewJolokiaRequest

func NewJolokiaRequest(requestType, mbeanName string, properties []string, attribute string) *JolokiaRequest

Creates a new Jolokia request

func (*JolokiaRequest) SetPath

func (jolokiaRequest *JolokiaRequest) SetPath(path string)

Set path to access tree node of json response

type JolokiaResponse

type JolokiaResponse struct {
	// Status of the request
	Status uint32
	// Timestamp value
	Timestamp uint32
	// Request
	Request map[string]interface{}
	// Result value
	Value map[string]interface{}
	// Error
	Error string
}

Jolokia Response for Generic request

type RequestData

type RequestData struct {
	Type  string `json:"type"`
	Mbean string `json:"mbean"`
	Path  string `json:"path"`
	//Attribute string `json:"attribute"`  -- Attribute get added manually
	Target `json:"target"`
}

The wrapper structure for json request

type Target

type Target struct {
	Url      string `json:"url"`
	Password string `json:"password"`
	User     string `json:"user"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL