// NetworkUsed returns a map of network utilization for processes in the cgroup. func (c *Cgroup) NetworkUsed(ifs []*net.Interface) (nuMap map[string]NetUsage, err error) { // Out usage map. nuMap = make(map[string]NetUsage, len(ifs)) for _, intf := range ifs { var err error sysDir := fmt.Sprintf("/sys/class/net/%s/statistics", intf.Name) txFile := filepath.Join(sysDir, "tx_bytes") rxFile := filepath.Join(sysDir, "rx_bytes") nu := NetUsage{} nu.TxBytes, err = proc.ReadInt64(txFile) if err != nil { return nil, err } nu.RxBytes, err = proc.ReadInt64(rxFile) if err != nil { return nil, err } nuMap[intf.Name] = nu } return nuMap, nil }
// MemoryUsed returns the total number of bytes used by processes in the cgroup. func (c *Cgroup) MemoryUsed() (int64, error) { return proc.ReadInt64(filepath.Join(cgroupsDir, "memory", c.name, "memory.usage_in_bytes")) }
// CPUUsed returns the total amount of cpu used by processes in the cgroup. func (c *Cgroup) CPUUsed() (i int64, err error) { return proc.ReadInt64(filepath.Join(cgroupsDir, "cpuacct", c.name, "cpuacct.usage")) }