libct/cg/fs2/hugetlb: use fscommon.GetValueByKey
This makes the code simpler and more future-proof, in case
any more values will appear in hugetlb.*.events.
@@ -4,7 +4,6 @@ package fs2
import (
"strconv"
- "strings"
"github.com/pkg/errors"
@@ -45,14 +44,10 @@ func statHugeTlb(dirPath string, stats *cgroups.Stats) error {
hugetlbStats.Usage = value
fileName := "hugetlb." + pagesize + ".events"
- contents, err := fscommon.ReadFile(dirPath, fileName)
+ value, err = fscommon.GetValueByKey(dirPath, fileName, "max")
if err != nil {
return errors.Wrap(err, "failed to read stats")
}
- _, value, err = fscommon.ParseKeyValue(strings.TrimSuffix(contents, "\n"))
- if err != nil {
- return errors.Wrap(err, "failed to parse "+fileName)
- }
hugetlbStats.Failcnt = value
stats.HugetlbStats[pagesize] = hugetlbStats
