2014-06-25 05:34:09 +08:00
|
|
|
package libcontainer
|
2014-06-14 09:31:12 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/libcontainer/cgroups/fs"
|
|
|
|
"github.com/docker/libcontainer/network"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Returns all available stats for the given container.
|
2014-06-27 04:49:02 +08:00
|
|
|
func GetStats(container *Config, state *State) (*ContainerStats, error) {
|
2014-06-26 13:04:20 +08:00
|
|
|
var containerStats ContainerStats
|
2014-06-14 09:31:12 +08:00
|
|
|
stats, err := fs.GetStats(container.Cgroups)
|
|
|
|
if err != nil {
|
2014-06-26 13:04:20 +08:00
|
|
|
return &containerStats, err
|
2014-06-14 09:31:12 +08:00
|
|
|
}
|
|
|
|
containerStats.CgroupStats = stats
|
2014-06-25 07:43:00 +08:00
|
|
|
networkStats, err := network.GetStats(&state.NetworkState)
|
2014-06-14 09:31:12 +08:00
|
|
|
if err != nil {
|
2014-06-26 13:04:20 +08:00
|
|
|
return &containerStats, err
|
2014-06-14 09:31:12 +08:00
|
|
|
}
|
|
|
|
containerStats.NetworkStats = networkStats
|
|
|
|
|
2014-06-26 13:04:20 +08:00
|
|
|
return &containerStats, nil
|
2014-06-14 09:31:12 +08:00
|
|
|
}
|