v2

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

README

Example REST API Client

This is an implementation of a cAdvisor REST API in Go. You can use it like this:

client, err := client.NewClient("http://192.168.59.103:8080/")

Obviously, replace the URL with the path to your actual cAdvisor REST endpoint.

MachineInfo
client.MachineInfo()

There is no v2 MachineInfo API, so the v2 client exposes the v1 MachineInfo

(*v1.MachineInfo)(0xc208022b10)({
 NumCores: (int) 4,
 MemoryCapacity: (int64) 2106028032,
 Filesystems: ([]v1.FsInfo) (len=1 cap=4) {
  (v1.FsInfo) {
   Device: (string) (len=9) "/dev/sda1",
   Capacity: (uint64) 19507089408
  }
 }
})

You can see the full specification of the MachineInfo struct in the source

VersionInfo
client.VersionInfo()

This method returns the cAdvisor version.

Attributes
client.Attributes()

This method returns a cadvisor/info/v2/Attributes struct with all the fields filled in. Attributes includes hardware attributes (as returned by MachineInfo) as well as software attributes (eg. software versions). Here is an example return value:

(*v2.Attributes)({
 KernelVersion: (string) (len=17) "3.13.0-44-generic"
 ContainerOsVersion: (string) (len=18) "Ubuntu 14.04.1 LTS"
 DockerVersion: (string) (len=9) "1.5.0-rc4"
 CadvisorVersion: (string) (len=6) "0.10.1"
 NumCores: (int) 4,
 MemoryCapacity: (int64) 2106028032,
 Filesystems: ([]v2.FsInfo) (len=1 cap=4) {
  (v2.FsInfo) {
   Device: (string) (len=9) "/dev/sda1",
   Capacity: (uint64) 19507089408
  }
 }
})

You can see the full specification of the Attributes struct in the source

Documentation

Overview

Client library to programmatically access cAdvisor API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the base URL for a cAdvisor client.

func NewClient

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

NewClient returns a new client with the specified base URL.

func (*Client) Attributes

func (self *Client) Attributes() (attr *v2.Attributes, err error)

Attributes returns hardware and software attributes of the machine.

func (*Client) MachineInfo

func (self *Client) MachineInfo() (minfo *v1.MachineInfo, err error)

MachineInfo returns the JSON machine information for this client. A non-nil error result indicates a problem with obtaining the JSON machine information data.

func (*Client) MachineStats added in v0.20.2

func (self *Client) MachineStats() ([]v2.MachineStats, error)

MachineStats returns the JSON machine statistics for this client. A non-nil error result indicates a problem with obtaining the JSON machine information data.

func (*Client) Stats added in v0.21.0

func (self *Client) Stats(name string, request *v2.RequestOptions) (map[string]v2.ContainerInfo, error)

Stats returns stats for the requested container.

func (*Client) VersionInfo

func (self *Client) VersionInfo() (version string, err error)

VersionInfo returns the version info for cAdvisor.

Jump to

Keyboard shortcuts

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