From abeb11c8a6f9549a519e262bee440071d4fd02c4 Mon Sep 17 00:00:00 2001 From: Svilen Markov <7613769+svilenmarkov@users.noreply.github.com> Date: Sat, 15 Feb 2025 14:43:25 +0000 Subject: [PATCH] Add hide-mountpoints-by-default prop for server-stats --- docs/configuration.md | 18 ++++++++++++++++++ pkg/sysinfo/sysinfo.go | 13 +++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 74d10c2..01afc8e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1852,11 +1852,29 @@ Whether to hide the swap usage. | Name | Type | Required | Default | | ---- | ---- | -------- | ------- | | cpu-temp-sensor | string | no | | +| hide-mointpoints-by-default | boolean | no | false | | mountpoints | map\[string\]object | no | | ###### `cpu-temp-sensor` The name of the sensor to use for the CPU temperature. When not provided the widget will attempt to find the correct one, if it fails to do so the temperature will not be displayed. To view the available sensors you can use `sensors` command. +###### `hide-mountpoints-by-default` +If set to `true` you'll have to manually make each mountpoint visible by adding a `hide: false` property to it like so: + +```yaml +- type: server-stats + servers: + - type: local + hide-mountpoints-by-default: true + mountpoints: + "/": + hide: false + "/mnt/data": + hide: false +``` + +This is useful if you're running Glance inside of a container which usually mounts a lot of irrelevant filesystems. + ###### `mountpoints` A map of mountpoints to display disk usage for. The key is the path to the mountpoint and the value is an object with optional properties. Example: diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index 3fd22ff..09df02f 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -74,13 +74,14 @@ type MountpointInfo struct { } type SystemInfoRequest struct { - CPUTempSensor string `yaml:"cpu-temp-sensor"` - Mountpoints map[string]MointpointRequest `yaml:"mountpoints"` + CPUTempSensor string `yaml:"cpu-temp-sensor"` + HideMountpointsByDefault bool `yaml:"hide-mountpoints-by-default"` + Mountpoints map[string]MointpointRequest `yaml:"mountpoints"` } type MointpointRequest struct { Name string `yaml:"name"` - Hide bool `yaml:"hide"` + Hide *bool `yaml:"hide"` } // Currently caches hostname indefinitely which isn't ideal @@ -229,7 +230,11 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) { if err == nil { for _, fs := range filesystems { mpReq, ok := req.Mountpoints[fs.Mountpoint] - if ok && mpReq.Hide { + isHidden := req.HideMountpointsByDefault + if ok && mpReq.Hide != nil { + isHidden = *mpReq.Hide + } + if isHidden { continue }