-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option for configuring the location of the container's host files…
…ystem (#2187) This allows the system module to read metrics related to the host machine rather than the container. When using the -system.hostfs flag, directories like /proc and /sys are assumed to be mounted relative to the path given in the value. Here's an example usage. `docker run --volume=/:/hostfs:ro --net=host --name=metricbeat -d metricbeat -system.hostfs=/hostfs` And here is a more restrictive example which does not mount all of the host's filesystems inside the container. system/filesystem will not be able to report metrics for the host's filesystem. `docker run --volume=/proc:/hostfs/proc:ro --volume=/sys/fs/cgroup:/hostfs/sys/fs/cgroup --net=host --name=metricbeat -d metricbeat -system.hostfs=/hostfs`
- Loading branch information
1 parent
e7211c5
commit 5ae6d88
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package system | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/elastic/gosigar" | ||
) | ||
|
||
func configureHostFS() { | ||
dir := *HostFS | ||
if dir == "" { | ||
dir = "/" | ||
} | ||
|
||
// Set environment variables for gopsutil. | ||
os.Setenv("HOST_PROC", filepath.Join(dir, "/proc")) | ||
os.Setenv("HOST_SYS", filepath.Join(dir, "/sys")) | ||
os.Setenv("HOST_ETC", filepath.Join(dir, "/etc")) | ||
|
||
// Set proc location for gosigar. | ||
gosigar.Procd = filepath.Join(dir, "/proc") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build !linux | ||
|
||
package system | ||
|
||
func configureHostFS() { | ||
// Stub method for non-linux. | ||
} |