properly strip path.rootfs from mountpoint labels (#1421)
Change-type: patch Connects-to: #1418 Signed-off-by: dt-rush <nickp@balena.io>
This commit is contained in:
parent
d8e47a9f9f
commit
5d3e2ce2ef
7 changed files with 44 additions and 3 deletions
|
|
@ -15,6 +15,7 @@ package collector
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/procfs"
|
||||
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
||||
|
|
@ -38,3 +39,10 @@ func sysFilePath(name string) string {
|
|||
func rootfsFilePath(name string) string {
|
||||
return filepath.Join(*rootfsPath, name)
|
||||
}
|
||||
|
||||
func rootfsStripPrefix(path string) string {
|
||||
if *rootfsPath == "/" {
|
||||
return path
|
||||
}
|
||||
return strings.TrimPrefix(path, *rootfsPath)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue