Exemple #1
0
// returns the container stats in json format.
func getContainerStats(container *libcontainer.Container) (string, error) {
	stats, err := fs.GetStats(container.Cgroups)
	if err != nil {
		return "", err
	}
	out, err := json.MarshalIndent(stats, "", "\t")
	if err != nil {
		return "", err
	}
	return string(out), nil
}
Exemple #2
0
func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err error) {
	if !self.isDockerContainer() {
		return
	}
	mi, err := self.machineInfoFactory.GetMachineInfo()
	if err != nil {
		return
	}
	parent, id, err := self.splitName()
	if err != nil {
		return
	}
	cg := &cgroups.Cgroup{
		Parent: parent,
		Name:   id,
	}
	s, err := fs.GetStats(cg)
	if err != nil {
		return
	}
	stats = libcontainerToContainerStats(s, mi)
	return
}