2014-06-17 12:53:39 +08:00
|
|
|
/*
|
|
|
|
Temporary API endpoint for libcontainer while the full API is finalized (api.go).
|
|
|
|
*/
|
|
|
|
package libcontainer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/libcontainer/cgroups/fs"
|
2014-07-12 03:00:27 +08:00
|
|
|
"github.com/docker/libcontainer/cgroups/systemd"
|
2014-06-17 12:53:39 +08:00
|
|
|
"github.com/docker/libcontainer/network"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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) {
|
2014-07-12 03:00:27 +08:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
stats = &ContainerStats{}
|
|
|
|
)
|
|
|
|
|
|
|
|
if systemd.UseSystemd() {
|
|
|
|
stats.CgroupStats, err = systemd.GetStats(container.Cgroups)
|
|
|
|
} else {
|
|
|
|
stats.CgroupStats, err = fs.GetStats(container.Cgroups)
|
2014-06-17 12:53:39 +08:00
|
|
|
}
|
2014-07-12 03:00:27 +08:00
|
|
|
|
2014-06-17 12:53:39 +08:00
|
|
|
if err != nil {
|
2014-07-12 03:00:27 +08:00
|
|
|
return stats, err
|
2014-06-17 12:53:39 +08:00
|
|
|
}
|
|
|
|
|
2014-07-12 03:00:27 +08:00
|
|
|
stats.NetworkStats, err = network.GetStats(&state.NetworkState)
|
|
|
|
|
|
|
|
return stats, err
|
2014-06-17 12:53:39 +08:00
|
|
|
}
|