示例#1
0
文件: cgutil.go 项目: beginnor/docker
func statsAction(context *cli.Context) {
	config, err := getConfig(context)
	if err != nil {
		log.Fatal(err)
	}
	stats, err := fs.GetStats(config)
	if err != nil {
		log.Fatal(err)
	}

	out, err := json.MarshalIndent(stats, "", "\t")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Usage stats for '%s':\n %v\n", config.Name, string(out))
}
示例#2
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
}