[continue 912] strip rootfs prefix for run in docker (#1058)
* strip rootfs prefix for run in docker * Use `/` as default value of path.rootfs, and parse mounts from `/proc/1/mounts`. * No need to mount `/proc` and `/sys` because we share host's PID namespace, which allows processes within the container to see all of the processes on the system. Closes: #66 Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com> Signed-off-by: Yecheng Fu <cofyc.jackson@gmail.com>
This commit is contained in:
parent
2269df255c
commit
0f9842f20a
4 changed files with 48 additions and 6 deletions
|
|
@ -70,7 +70,7 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
|||
go stuckMountWatcher(labels.mountPoint, success)
|
||||
|
||||
buf := new(syscall.Statfs_t)
|
||||
err = syscall.Statfs(labels.mountPoint, buf)
|
||||
err = syscall.Statfs(rootfsFilePath(labels.mountPoint), buf)
|
||||
|
||||
stuckMountsMtx.Lock()
|
||||
close(success)
|
||||
|
|
@ -86,7 +86,7 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
|||
labels: labels,
|
||||
deviceError: 1,
|
||||
})
|
||||
log.Debugf("Error on statfs() system call for %q: %s", labels.mountPoint, err)
|
||||
log.Debugf("Error on statfs() system call for %q: %s", rootfsFilePath(labels.mountPoint), err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ func stuckMountWatcher(mountPoint string, success chan struct{}) {
|
|||
}
|
||||
|
||||
func mountPointDetails() ([]filesystemLabels, error) {
|
||||
file, err := os.Open(procFilePath("mounts"))
|
||||
file, err := os.Open(procFilePath("1/mounts"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue