Пример #1
0
func (self *cadvisorSource) getAllContainers(client *cadvisorClient.Client, start, end time.Time, resolution time.Duration, align bool) (subcontainers []*api.Container, root *api.Container, err error) {
	allContainers, err := client.SubcontainersInfo("/", &cadvisor.ContainerInfoRequest{Start: start, End: end})
	if err != nil {
		return nil, nil, err
	}

	for _, containerInfo := range allContainers {
		container := parseStat(&containerInfo, start, resolution, align)
		if containerInfo.Name == "/" {
			root = container
		} else {
			subcontainers = append(subcontainers, container)
		}
	}

	return subcontainers, root, nil
}
Пример #2
0
func (self *cadvisorSource) getAllContainers(client *cadvisorClient.Client, numStats int) (subcontainers []*api.Container, root *api.Container, err error) {
	allContainers, err := client.SubcontainersInfo("/",
		&cadvisor.ContainerInfoRequest{NumStats: numStats})
	if err != nil {

		return nil, nil, err
	}

	for _, containerInfo := range allContainers {
		container := self.parseStat(&containerInfo)
		if containerInfo.Name == "/" {
			root = container
		} else {
			subcontainers = append(subcontainers, container)
		}
	}

	return subcontainers, root, nil
}
Пример #3
0
// Get all containers from cAdvisor and separates the root container and other contianers.
func (self *CadvisorSource) getAllContainers(client *cadvisorClient.Client, start, end time.Time) (subcontainers []*Container, root *Container, err error) {
	allContainers, err := client.SubcontainersInfo("/",
		&cadvisor.ContainerInfoRequest{})
	if err != nil {
		glog.Errorf("Got error when trying to get container info: %v", err)
		return nil, nil, err
	}

	for _, containerInfo := range allContainers {
		container := self.parseStat(&containerInfo)
		if containerInfo.Name == "/" {
			root = container
		} else {
			subcontainers = append(subcontainers, container)
		}
	}

	return subcontainers, root, nil
}
Пример #4
0
func getContainerInfo(client *client.Client, container string) (containerInfo info.ContainerInfo, err error) {
	query := info.ContainerInfoRequest{}
	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)
}
Пример #5
0
func GetAllContainer(client *client.Client) ([]info.ContainerInfo, error) {
	query := info.ContainerInfoRequest{}
	query.NumStats = 1
	cinfos, err := client.SubcontainersInfo("/", &query)
	return cinfos, err
}