Skip to content

Commit abeb11c

Browse files
committed
Add hide-mountpoints-by-default prop for server-stats
1 parent e01af4a commit abeb11c

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

docs/configuration.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,11 +1852,29 @@ Whether to hide the swap usage.
18521852
| Name | Type | Required | Default |
18531853
| ---- | ---- | -------- | ------- |
18541854
| cpu-temp-sensor | string | no | |
1855+
| hide-mointpoints-by-default | boolean | no | false |
18551856
| mountpoints | map\[string\]object | no | |
18561857

18571858
###### `cpu-temp-sensor`
18581859
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.
18591860

1861+
###### `hide-mountpoints-by-default`
1862+
If set to `true` you'll have to manually make each mountpoint visible by adding a `hide: false` property to it like so:
1863+
1864+
```yaml
1865+
- type: server-stats
1866+
servers:
1867+
- type: local
1868+
hide-mountpoints-by-default: true
1869+
mountpoints:
1870+
"/":
1871+
hide: false
1872+
"/mnt/data":
1873+
hide: false
1874+
```
1875+
1876+
This is useful if you're running Glance inside of a container which usually mounts a lot of irrelevant filesystems.
1877+
18601878
###### `mountpoints`
18611879
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:
18621880

pkg/sysinfo/sysinfo.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@ type MountpointInfo struct {
7474
}
7575

7676
type SystemInfoRequest struct {
77-
CPUTempSensor string `yaml:"cpu-temp-sensor"`
78-
Mountpoints map[string]MointpointRequest `yaml:"mountpoints"`
77+
CPUTempSensor string `yaml:"cpu-temp-sensor"`
78+
HideMountpointsByDefault bool `yaml:"hide-mountpoints-by-default"`
79+
Mountpoints map[string]MointpointRequest `yaml:"mountpoints"`
7980
}
8081

8182
type MointpointRequest struct {
8283
Name string `yaml:"name"`
83-
Hide bool `yaml:"hide"`
84+
Hide *bool `yaml:"hide"`
8485
}
8586

8687
// Currently caches hostname indefinitely which isn't ideal
@@ -229,7 +230,11 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
229230
if err == nil {
230231
for _, fs := range filesystems {
231232
mpReq, ok := req.Mountpoints[fs.Mountpoint]
232-
if ok && mpReq.Hide {
233+
isHidden := req.HideMountpointsByDefault
234+
if ok && mpReq.Hide != nil {
235+
isHidden = *mpReq.Hide
236+
}
237+
if isHidden {
233238
continue
234239
}
235240

0 commit comments

Comments
 (0)