Example #1
0
// TODO(vmarmol): Complete Stats() in final libcontainer API and move users to that.
// DEPRECATED: The below portions are only to be used during the transition to the official API.
// Returns all available stats for the given container.
func GetStats(container *Config, state *State) (stats *ContainerStats, err error) {
	stats = &ContainerStats{}
	if stats.CgroupStats, err = fs.GetStats(state.CgroupPaths); err != nil {
		return stats, err
	}
	stats.NetworkStats, err = network.GetStats(&state.NetworkState)
	return stats, err
}
Example #2
0
// Get stats of the specified container
func GetStats(cgroup *cgroups.Cgroup, state *libcontainer.State) (*info.ContainerStats, error) {
	// TODO(vmarmol): Use libcontainer's Stats() in the new API when that is ready.
	stats := &libcontainer.ContainerStats{}

	var err error
	stats.CgroupStats, err = cgroupfs.GetStats(cgroup)
	if err != nil {
		return &info.ContainerStats{}, err
	}

	stats.NetworkStats, err = network.GetStats(&state.NetworkState)
	return toContainerStats(stats), nil
}
Example #3
0
File: api.go Project: 98pm/docker
// Returns all available stats for the given container.
func GetStats(container *Config, state *State) (*ContainerStats, error) {
	var containerStats ContainerStats
	stats, err := fs.GetStats(container.Cgroups)
	if err != nil {
		return &containerStats, err
	}
	containerStats.CgroupStats = stats
	networkStats, err := network.GetStats(&state.NetworkState)
	if err != nil {
		return &containerStats, err
	}
	containerStats.NetworkStats = networkStats

	return &containerStats, nil
}
Example #4
0
// TODO(vmarmol): Complete Stats() in final libcontainer API and move users to that.
// DEPRECATED: The below portions are only to be used during the transition to the official API.
// Returns all available stats for the given container.
func GetStats(container *Config, state *State) (*ContainerStats, error) {
	var (
		err   error
		stats = &ContainerStats{}
	)

	if systemd.UseSystemd() {
		stats.CgroupStats, err = systemd.GetStats(container.Cgroups)
	} else {
		stats.CgroupStats, err = fs.GetStats(container.Cgroups)
	}

	if err != nil {
		return stats, err
	}

	stats.NetworkStats, err = network.GetStats(&state.NetworkState)

	return stats, err
}