update procfs to latest (#1335)
Updates for procfs refactoring Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
parent
c7abeae816
commit
86f9079429
33 changed files with 1966 additions and 1382 deletions
46
vendor/github.com/prometheus/procfs/bcache/get.go
generated
vendored
46
vendor/github.com/prometheus/procfs/bcache/get.go
generated
vendored
|
|
@ -22,8 +22,54 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs/internal/fs"
|
||||
)
|
||||
|
||||
// FS represents the pseudo-filesystem proc, which provides an interface to
|
||||
// kernel data structures.
|
||||
type FS struct {
|
||||
sys *fs.FS
|
||||
}
|
||||
|
||||
// NewFS returns a new Bcache using the given sys fs mount point. It will error
|
||||
// if the mount point can't be read.
|
||||
func NewFS(mountPoint string) (FS, error) {
|
||||
if strings.TrimSpace(mountPoint) == "" {
|
||||
mountPoint = fs.DefaultSysMountPoint
|
||||
}
|
||||
fs, err := fs.NewFS(mountPoint)
|
||||
if err != nil {
|
||||
return FS{}, err
|
||||
}
|
||||
return FS{&fs}, nil
|
||||
}
|
||||
|
||||
// Stats retrieves bcache runtime statistics for each bcache.
|
||||
func (fs FS) Stats() ([]*Stats, error) {
|
||||
matches, err := filepath.Glob(fs.sys.Path("fs/bcache/*-*"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stats := make([]*Stats, 0, len(matches))
|
||||
for _, uuidPath := range matches {
|
||||
// "*-*" in glob above indicates the name of the bcache.
|
||||
name := filepath.Base(uuidPath)
|
||||
|
||||
// stats
|
||||
s, err := GetStats(uuidPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.Name = name
|
||||
stats = append(stats, s)
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// ParsePseudoFloat parses the peculiar format produced by bcache's bch_hprint.
|
||||
func parsePseudoFloat(str string) (float64, error) {
|
||||
ss := strings.Split(str, ".")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue