github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/client/lib/container_stats.go (about)

     1  package lib
     2  
     3  import (
     4  	"io"
     5  	"net/url"
     6  )
     7  
     8  // ContainerStats returns near realtime stats for a given container.
     9  // It's up to the caller to close the io.ReadCloser returned.
    10  func (cli *Client) ContainerStats(containerID string, stream bool) (io.ReadCloser, error) {
    11  	query := url.Values{}
    12  	query.Set("stream", "0")
    13  	if stream {
    14  		query.Set("stream", "1")
    15  	}
    16  
    17  	resp, err := cli.get("/containers/"+containerID+"/stats", query, nil)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  	return resp.body, err
    22  }