Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #420 from LK4D4/systemd_stats
Browse files Browse the repository at this point in the history
Implement stats for systemd
  • Loading branch information
crosbymichael committed Mar 3, 2015
2 parents 56bc148 + dd5576b commit 6c2f20e
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion cgroups/systemd/apply_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ type subsystem interface {
GetStats(string, *cgroups.Stats) error
}

var subsystems = map[string]subsystem{
"devices": &fs.DevicesGroup{},
"memory": &fs.MemoryGroup{},
"cpu": &fs.CpuGroup{},
"cpuset": &fs.CpusetGroup{},
"cpuacct": &fs.CpuacctGroup{},
"blkio": &fs.BlkioGroup{},
"perf_event": &fs.PerfEventGroup{},
"freezer": &fs.FreezerGroup{},
}

var (
connLock sync.Mutex
theConn *systemd.Conn
Expand Down Expand Up @@ -298,7 +309,18 @@ func (m *Manager) GetPids() ([]int, error) {
}

func (m *Manager) GetStats() (*cgroups.Stats, error) {
panic("not implemented")
stats := cgroups.NewStats()
for name, path := range m.Paths {
sys, ok := subsystems[name]
if !ok || !cgroups.PathExists(path) {
continue
}
if err := sys.GetStats(path, stats); err != nil {
return nil, err
}
}

return stats, nil
}

func getUnitName(c *configs.Cgroup) string {
Expand Down

0 comments on commit 6c2f20e

Please sign in to comment.