add function to get string value from cgroup file

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-02-13 14:03:15 +08:00
parent 1db687f4f4
commit 74005ed4e0
1 changed files with 10 additions and 0 deletions

View File

@ -60,3 +60,13 @@ func getCgroupParamUint(cgroupPath, cgroupFile string) (uint64, error) {
return parseUint(strings.TrimSpace(string(contents)), 10, 64)
}
// Gets a string value from the specified cgroup file
func getCgroupParamString(cgroupPath, cgroupFile string) (string, error) {
contents, err := ioutil.ReadFile(filepath.Join(cgroupPath, cgroupFile))
if err != nil {
return "", err
}
return strings.TrimSpace(string(contents)), nil
}