Added failcnt stats
Signed-off-by: Boris Popovschi <zyqsempai@mail.ru>
This commit is contained in:
parent
7f37afa892
commit
d804611d05
|
@ -3,10 +3,13 @@
|
||||||
package fs2
|
package fs2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||||
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
||||||
"github.com/opencontainers/runc/libcontainer/configs"
|
"github.com/opencontainers/runc/libcontainer/configs"
|
||||||
|
@ -24,20 +27,26 @@ func setHugeTlb(dirPath string, cgroup *configs.Cgroup) error {
|
||||||
|
|
||||||
func statHugeTlb(dirPath string, stats *cgroups.Stats, cgroup *configs.Cgroup) error {
|
func statHugeTlb(dirPath string, stats *cgroups.Stats, cgroup *configs.Cgroup) error {
|
||||||
hugetlbStats := cgroups.HugetlbStats{}
|
hugetlbStats := cgroups.HugetlbStats{}
|
||||||
|
|
||||||
for _, entry := range cgroup.Resources.HugetlbLimit {
|
for _, entry := range cgroup.Resources.HugetlbLimit {
|
||||||
max := strings.Join([]string{"hugetlb", entry.Pagesize, "max"}, ".")
|
usage := strings.Join([]string{"hugetlb", entry.Pagesize, "current"}, ".")
|
||||||
value, err := fscommon.GetCgroupParamUint(dirPath, max)
|
value, err := fscommon.GetCgroupParamUint(dirPath, usage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse %s - %v", max, err)
|
return errors.Wrapf(err, "failed to parse hugetlb.%s.current file", entry.Pagesize)
|
||||||
}
|
}
|
||||||
hugetlbStats.Usage = value
|
hugetlbStats.Usage = value
|
||||||
|
|
||||||
usage := strings.Join([]string{"hugetlb", entry.Pagesize, "current"}, ".")
|
fileName := strings.Join([]string{"hugetlb", entry.Pagesize, "events"}, ".")
|
||||||
value, err = fscommon.GetCgroupParamUint(dirPath, usage)
|
filePath := filepath.Join(dirPath, fileName)
|
||||||
|
contents, err := ioutil.ReadFile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse %s - %v", usage, err)
|
return errors.Wrapf(err, "failed to parse hugetlb.%s.events file", entry.Pagesize)
|
||||||
}
|
}
|
||||||
hugetlbStats.Usage = value
|
_, value, err = fscommon.GetCgroupParamKeyValue(string(contents))
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to parse hugetlb.%s.events file", entry.Pagesize)
|
||||||
|
}
|
||||||
|
hugetlbStats.Failcnt = value
|
||||||
|
|
||||||
stats.HugetlbStats[entry.Pagesize] = hugetlbStats
|
stats.HugetlbStats[entry.Pagesize] = hugetlbStats
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue