cadvisor/client
Victor Marmol 181e12dda2 Refactoring and fixes of /docker API endpoint.
This canges the output of the Docker endpoint to be a map so that it is
more consistent from single to multiple returns. It also refactors
internally how we handle both types of requests.

Without this PR the /docker API endpoint is broken completely so this
change in format has no effect anyways.

These changes are tested by the upcoming integration tests.
2014-11-19 03:36:18 -08:00
..
client_test.go Refactoring and fixes of /docker API endpoint. 2014-11-19 03:36:18 -08:00
client.go Refactoring and fixes of /docker API endpoint. 2014-11-19 03:36:18 -08:00
README.md Made changes to client docs as recommended by @vmarmol 2014-10-20 08:42:03 -10:00

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()

This method returns a cadvisor/info.MachineInfo struct with all the fields filled in. Here is an example return value:

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

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

ContainerInfo

Given a container name and a ContainerInfoRequest, will return all information about the specified container. The ContainerInfoRequest struct just has one field, NumStats, which is the number of stat entries that you want returned.

request := info.ContainerInfoRequest{10}
sInfo, err := client.ContainerInfo("/docker/d9d3eb10179e6f93a...", &request)

Returns a ContainerInfo struct

SubcontainersInfo

Given a container name and a ContainerInfoRequest, will recursively return all info about the container and all subcontainers contained within the container. The ContainerInfoRequest struct just has one field, NumStats, which is the number of stat entries that you want returned.

request := info.ContainerInfoRequest{10}
sInfo, err := client.SubcontainersInfo("/docker", &request)

Returns a ContainerInfo struct with the Subcontainers field populated.