committed by
Cameron Sparr
parent
4c8449f4bc
commit
0b9b7bddd7
@@ -16,6 +16,14 @@ https://en.wikipedia.org/wiki/Df_(Unix) for more details.
|
||||
# mount_points = ["/"]
|
||||
```
|
||||
|
||||
Additionally, the behavior of resolving the `mount_points` can be configured by using the `HOST_MOUNT_PREFIX` environment variable.
|
||||
When present, this variable is prepended to the mountpoints discovered by the plugin before retrieving stats.
|
||||
The prefix is stripped from the reported `path` in the measurement.
|
||||
This settings is useful when running `telegraf` inside a docker container to report host machine metrics.
|
||||
In this case, the host's root volume should be mounted into the container and the `HOST_MOUNT_PREFIX` and `HOST_ETC` environment variables set.
|
||||
|
||||
`docker run -v /:/hostfs:ro -e HOST_MOUNT_PREFIX=/hostfs -e HOST_ETC=/hostfs/etc telegraf-docker`
|
||||
|
||||
### Measurements & Fields:
|
||||
|
||||
- disk
|
||||
|
||||
@@ -81,8 +81,10 @@ func (s *systemPS) DiskUsage(
|
||||
continue
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(p.Mountpoint); err == nil {
|
||||
du, err := disk.DiskUsage(p.Mountpoint)
|
||||
mountpoint := os.Getenv("HOST_MOUNT_PREFIX") + p.Mountpoint
|
||||
if _, err := os.Stat(mountpoint); err == nil {
|
||||
du, err := disk.DiskUsage(mountpoint)
|
||||
du.Path = p.Mountpoint
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user