2014-10-23 04:45:23 +08:00
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package libcontainer
|
|
|
|
|
2014-10-23 07:53:28 +08:00
|
|
|
import "github.com/docker/libcontainer/network"
|
2014-10-23 04:45:23 +08:00
|
|
|
|
|
|
|
type linuxContainer struct {
|
2014-10-23 07:53:28 +08:00
|
|
|
id string
|
|
|
|
root string
|
|
|
|
config *Config
|
|
|
|
state *State
|
|
|
|
cgroupManager CgroupManager
|
2014-10-23 04:45:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) ID() string {
|
|
|
|
return c.id
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *linuxContainer) Config() *Config {
|
|
|
|
return c.config
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:53:28 +08:00
|
|
|
func (c *linuxContainer) RunState() (RunState, error) {
|
2014-10-23 04:45:23 +08:00
|
|
|
panic("not implemented")
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:27:06 +08:00
|
|
|
func (c *linuxContainer) Processes() ([]int, error) {
|
2014-10-23 07:53:28 +08:00
|
|
|
pids, err := c.cgroupManager.GetPids(c.config.Cgroups)
|
2014-10-23 04:45:23 +08:00
|
|
|
if err != nil {
|
|
|
|
return nil, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
return pids, nil
|
|
|
|
}
|
|
|
|
|
2014-10-23 07:27:06 +08:00
|
|
|
func (c *linuxContainer) Stats() (*ContainerStats, error) {
|
2014-10-23 04:45:23 +08:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
stats = &ContainerStats{}
|
|
|
|
)
|
|
|
|
|
2014-10-23 07:53:28 +08:00
|
|
|
if stats.CgroupStats, err = c.cgroupManager.GetStats(c.config.Cgroups); err != nil {
|
2014-10-23 04:45:23 +08:00
|
|
|
return stats, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
if stats.NetworkStats, err = network.GetStats(&c.state.NetworkState); err != nil {
|
|
|
|
return stats, newGenericError(err, SystemError)
|
|
|
|
}
|
|
|
|
return stats, nil
|
|
|
|
}
|