コード例 #1
0
ファイル: handler.go プロジェクト: vrosnet/kubernetes
func getContainerInfoRequest(body io.ReadCloser) (*info.ContainerInfoRequest, error) {
	var query info.ContainerInfoRequest

	// Default stats and samples is 64.
	query.NumStats = 64

	decoder := json.NewDecoder(body)
	err := decoder.Decode(&query)
	if err != nil && err != io.EOF {
		return nil, fmt.Errorf("unable to decode the json value: %s", err)
	}

	return &query, nil
}
コード例 #2
0
func getContainerInfo(client *client.Client, container string) (containerInfo info.ContainerInfo, err error) {
	query := info.ContainerInfoRequest{}
	query.NumStats = 1
	cinfos, err := client.SubcontainersInfo("/", &query)
	if err != nil {
		return info.ContainerInfo{}, err
	}
	tempContainer := "/" + container
	for _, cinfo := range cinfos {
		if strings.HasSuffix(cinfo.Name, tempContainer) {
			return cinfo, nil
		}
	}
	return info.ContainerInfo{}, errors.New("not find container " + container)
}
コード例 #3
0
ファイル: memorymonitor.go プロジェクト: hustcts/ocp-testing
func GetAllContainer(client *client.Client) ([]info.ContainerInfo, error) {
	query := info.ContainerInfoRequest{}
	query.NumStats = 1
	cinfos, err := client.SubcontainersInfo("/", &query)
	return cinfos, err
}